Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
node_modules
npm-debug.log
.git
.gitignore
README.md
.env
.env.*
config/*.env
dist
build
coverage
logs
*.log
.DS_Store
.vscode
.idea
*.md
docker-compose*.yml
Dockerfile
.github
.gitlab-ci.yml
.travis.yml
.circleci

1 change: 0 additions & 1 deletion .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
publish:
needs: run-linters
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: read
packages: write
Expand Down
42 changes: 33 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#https://hub.docker.com/_/node?tab=tags&page=1
FROM node:20.11.0-alpine3.18
# https://hub.docker.com/_/node?tab=tags&page=1
# Build stage
FROM node:20.11.0-alpine3.18 AS builder

WORKDIR /usr/src/app


COPY package*.json ./
COPY patches ./patches
COPY tsconfig.json .


RUN apk add --update alpine-sdk
RUN apk add git python3
RUN apk add --no-cache chromium --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/main
RUN npm ci
RUN npm i -g ts-node
# Combine RUN commands to reduce layers
RUN apk add --update --no-cache \
alpine-sdk \
git \
python3 \
chromium --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/main && \
npm ci && \
npm i -g ts-node

# When building docker images, docker caches the steps, so it's better to put the lines that would have lots of changes
# last, then when changing these steps the previous steps would use cache and move forward fast
Expand All @@ -23,3 +25,25 @@ COPY test ./test
COPY migration ./migration

RUN npm run build

# Production stage
FROM node:20.11.0-alpine3.18

WORKDIR /usr/src/app

# Copy package files and install only production dependencies
COPY package*.json ./
COPY patches ./patches

RUN npm ci --omit=dev

# Copy built files from builder stage
COPY --from=builder /usr/src/app/build ./build
COPY migration ./migration

# Add non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /usr/src/app

USER nodejs