Skip to content

Commit

Permalink
Merge pull request #2 from vividroyjeong/feature/docker
Browse files Browse the repository at this point in the history
Add and modify Dockerfile and related files
  • Loading branch information
vividroyjeong authored Aug 30, 2024
2 parents 2fdf0d1 + 84dea26 commit ae832ee
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 22 deletions.
6 changes: 6 additions & 0 deletions vdyp-web-ui/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea
.vscode
coverage
cypress
dist
node_modules
48 changes: 48 additions & 0 deletions vdyp-web-ui/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"
}
}
30 changes: 30 additions & 0 deletions vdyp-web-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Build static files
# Node Bullseye has npm
FROM node:20.16.0-bullseye-slim AS build

# Install packages, build and keep only prod packages
WORKDIR /app
COPY *.json *.ts index.html ./
COPY public ./public
COPY ./src ./src
RUN npm ci --ignore-scripts --no-update-notifier --omit=dev && \
npm run build-only

# Deploy container
# Caddy serves static files
FROM caddy:2.8.4-alpine

# Install packages and ensure permissions in one RUN command
RUN apk add --no-cache ca-certificates && \
mkdir -p /config/caddy /data/caddy && \
chown -R 1001:1001 /config/caddy /data/caddy

# Copy static files and run formatting
COPY --from=build /app/dist /srv
COPY Caddyfile /etc/caddy/Caddyfile
RUN caddy fmt --overwrite /etc/caddy/Caddyfile

# Ports, health check and non-root user
EXPOSE 3000 3001
HEALTHCHECK --interval=30s --timeout=3s CMD ["curl", "-f", "http://localhost:3001/health"]
USER 1001
32 changes: 14 additions & 18 deletions vdyp-web-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vdyp-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"repository": {},
"dependencies": {
"@bcgov/bc-sans": "^2.1.0",
"@mdi/font": "^7.4.47",
"@tsconfig/node20": "^20.1.4",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/tsconfig": "^0.5.1",
"@vuepic/vue-datepicker": "^8.8.0",
"axios": "^1.7.2",
"http-status-codes": "^2.3.0",
Expand All @@ -31,14 +35,10 @@
"vuetify": "^3.6.14"
},
"devDependencies": {
"@mdi/font": "^7.4.47",
"@rushstack/eslint-patch": "^1.8.0",
"@tsconfig/node20": "^20.1.4",
"@types/node": "^20.14.5",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.57.0",
"npm-run-all2": "^6.2.0",
"prettier": "^3.3.3",
Expand Down

0 comments on commit ae832ee

Please sign in to comment.