Skip to content

Commit

Permalink
Deploy to d2s (#158)
Browse files Browse the repository at this point in the history
* Docker setup done

* Fix basic auth

* Added GitHub Actions
  • Loading branch information
mpcontracting authored Jul 13, 2023
1 parent df3db05 commit 48810f9
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Create release

on:
pull_request:
branches:
- main
types: [closed]

jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for the PR label
id: label
uses: zwaldowski/match-label-action@v4
with:
allowed: major,minor,patch
- name: Bump the version tag
id: next_version
uses: zwaldowski/semver-release-action@v3
with:
bump: ${{ steps.label.outputs.match }}
prefix: v
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: create-release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.next_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/pre_merge_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Pre-merge check

on:
pull_request:
branches:
- main
types: [opened, reopened, synchronize, labeled]

jobs:
check_pull_request_label:
name: Check pull request label
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for the PR label
id: label
uses: zwaldowski/match-label-action@v4
with:
allowed: major,minor,patch
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Build stage
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS builder

USER root
WORKDIR /app-build

COPY package.json /app-build/
COPY package-lock.json /app-build/
RUN npm ci

COPY . /app-build
RUN npm run build

# Copy to the RedHat Nginx image
FROM registry.access.redhat.com/ubi9/nginx-120:latest

COPY --from=builder /app-build/public "${HOME}"

COPY nginx/startup.sh /opt/app-root/startup.sh
COPY nginx/logging.conf "${NGINX_CONFIGURATION_PATH}"

CMD /opt/app-root/startup.sh
6 changes: 6 additions & 0 deletions nginx/logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
log_format ddsoc '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /dev/stdout ddsoc;
error_log /dev/stderr info;
17 changes: 17 additions & 0 deletions nginx/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

echo "Starting Nginx"
echo "=============="
echo ""
echo "Is Prod : $IS_PROD"
echo "Basic Auth : $BASIC_AUTH"
echo "Password : $HTPASSWD"

# If this is not prod, add basic auth
if [ "$IS_PROD" = 'false' ]; then
echo "Not production - implementing basic auth"
echo $BASIC_AUTH | base64 -d > /opt/app-root/etc/nginx.default.d/basic-auth.conf
echo $HTPASSWD | base64 -d > /opt/app-root/etc/.htpasswd
fi

nginx -g 'daemon off;'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"npm": "~8.15.0"
},
"scripts": {
"build": "gulp build & npx eleventy",
"dev": "gulp build & npx eleventy --serve",
"build": "gulp build && npx eleventy",
"dev": "gulp build && npx eleventy --serve",
"prototype": "gulp clean && cross-env ELEVENTY_ENV=prototype npx eleventy && cross-env ELEVENTY_ENV=prototype gulp prod",
"prod": "gulp clean && cross-env ELEVENTY_ENV=production npx eleventy && cross-env ELEVENTY_ENV=production gulp prod",
"test": "npx @11ty/eleventy & gulp validator"
Expand Down

0 comments on commit 48810f9

Please sign in to comment.