Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): deploy frontend #69

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ jobs:
# environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
# - name: Deploy Frontend
# uses: bcgov-nr/action-deployer-openshift@v3.0.0
# with:
# oc_namespace: ${{ vars.OC_NAMESPACE }}
# oc_server: ${{ vars.OC_SERVER }}
# oc_token: ${{ secrets.OC_TOKEN }}
# file: frontend/openshift.deploy.yml
# overwrite: true
# parameters:
# -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }}

- name: Database
uses: bcgov-nr/action-deployer-openshift@v3.0.0
with:
Expand Down Expand Up @@ -97,7 +86,7 @@ jobs:
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
file: backend/openshift.backend.yml
file: backend/openshift.deploy.yml
parameters:
-p NAME_SUFFIX=-dev-${{ github.event.number }}
-p ENV_NAME=dev
Expand Down Expand Up @@ -128,3 +117,20 @@ jobs:
-p ENABLE_AQUIFERS_SEARCH=${{ vars.ENABLE_AQUIFERS_SEARCH }}
-p EMAIL_NOTIFICATION_RECIPIENT=${{ vars.EMAIL_NOTIFICATION_RECIPIENT }}
-p GEOCODER_ADDRESS_API_BASE=${{ vars.GEOCODER_ADDRESS_API_BASE }}

frontend:
name: Frontend
needs: [ init, database, backend ]
# environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
- name: Deploy Frontend
uses: bcgov-nr/action-deployer-openshift@v3.0.0
with:
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
file: frontend/openshift.deploy.yml
parameters:
-p TAG=-dev-${{ github.event.number }}
-p TARGET=dev
2 changes: 1 addition & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
package: [database, backend]
package: [database, backend, frontend]
timeout-minutes: 20
steps:
- uses: bcgov-nr/action-builder-ghcr@v2.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ parameters:
value: 500m
- name: MEMORY_REQUEST
required: false
value: 2Gi
value: 1Gi
- name: MEMORY_LIMIT
required: false
value: 4Gi
value: 2Gi
- name: PSQL_IMAGE
description: A psql client image (a PostgreSQL image will suffice)
required: true
Expand Down
48 changes: 48 additions & 0 deletions frontend/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
auto_https off
admin 0.0.0.0:3003
servers {
metrics
}
}
:3000 {
log {
output stdout
format console {
time_format iso8601
level_format color
}
level {$LOG_LEVEL}
}
root * /srv
encode zstd gzip
file_server
@spa_router {
not path /api*
file {
try_files {path} /index.html
}
}
rewrite @spa_router {http.matchers.file.relative}
# Proxy requests to API service
reverse_proxy /api* {$BACKEND_URL} {
header_up Host {http.reverse_proxy.upstream.hostport}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
}
header {
X-Frame-Options "SAMEORIGIN"
X-XSS-Protection "1;mode=block"
Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"
X-Content-Type-Options "nosniff"
Strict-Transport-Security "max-age=31536000"
Content-Security-Policy "default-src 'self' https://spt.apps.gov.bc.ca data:; script-src 'self' 'unsafe-eval' https://www2.gov.bc.ca ;style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://use.fontawesome.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https://fonts.googleapis.com http://www.w3.org https://*.gov.bc.ca"
Referrer-Policy "same-origin"
Feature-Policy "fullscreen 'self'; camera 'none'; microphone 'none'"
}
}
:3001 {
handle /health {
respond "OK"
}
}
29 changes: 18 additions & 11 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
FROM node:14.21.3 AS build

RUN apt-get update && apt-get install -y \
git \
build-essential \
python3 \
python3-pip \
make \
g++
ENV LOG_LEVEL="info"

RUN apt-get update

RUN apt-get install -y git build-essential python3 python3-pip make g++

WORKDIR /app

COPY package*.json ./

RUN npm i
RUN npm install

COPY . /app

RUN npm run build

FROM node:14.21.3
FROM caddy:2

# Copy static files, verify Caddyfile formatting
COPY --from=build /app/dist /srv
COPY Caddyfile /etc/caddy/Caddyfile
RUN caddy fmt /etc/caddy/Caddyfile

CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]

# FROM node:14.21.3

COPY --from=build /app /app
# COPY --from=build /app /app

# CMD ["npm run serve"]
# CMD ["npm" "run" "serve"]
5 changes: 4 additions & 1 deletion frontend/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ objects:
spec:
containers:
- name: ${APP}-${TARGET}-${COMPONENT}
image: ghcr.io/${ORG}/${APP}/${COMPONENT}:${TAG}
# image: ghcr.io/${ORG}/${APP}/${COMPONENT}:${TAG}
image: ghcr.io/bcgov/nr-gwells/frontend:69
# securityContext:
# runAsUser: 1011540000
imagePullPolicy: Always
Expand All @@ -63,6 +64,8 @@ objects:
value: info
- name: VUE_APP_AXIOS_BASE_URL
value: http://${APP}-${TARGET}/gwells/api/v2/
- name: BACKEND_URL
value: http://${APP}-${TARGET}/gwells/api/v2/
ports:
- name: http
containerPort: 5173
Expand Down
Loading