Skip to content

Commit

Permalink
feat: add prod docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Oct 7, 2024
1 parent 0188620 commit 69b0a35
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 79 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sample.env
.env
README.md
eslint.config.js
.github
docs
node_modules
tests
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG NODE_VERSION=20.16.0

FROM node:${NODE_VERSION}-alpine as builder
WORKDIR /app

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

COPY . .

FROM node:${NODE_VERSION}-alpine

WORKDIR /app
USER node

COPY --from=builder /app .

ARG PORT=4000
ENV PORT $PORT
EXPOSE $PORT
6 changes: 6 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ services:
POSTGRES_DB: ucpa_facilitator
env_file:
- .env

chrome:
image: ghcr.io/browserless/chromium
container_name: chrome
ports:
- '3000:3000'
5 changes: 4 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getParsedJson(environmentVariable) {
function buildConfiguration() {
const config = {
environment: env.NODE_ENV || 'development',
port: env.PORT || 3000,
port: env.PORT || 4000,
baseURL: env.BASE_URL || 'http://example.net',
secret: env.SECRET,
logging: {
Expand Down Expand Up @@ -60,6 +60,9 @@ function buildConfiguration() {
passTypeIdentifier: env.PASS_TYPE_IDENTIFIER,
teamIdentifier: env.PASS_TEAM_IDENTIFIER,
},
browser: {
browserWSEndpoint: env.BROWSER_WS_ENDPOINT,
},
};
if (config.environment === 'test') {
config.logging.enabled = false;
Expand Down
Loading

0 comments on commit 69b0a35

Please sign in to comment.