Skip to content

Commit

Permalink
chore: enhance docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
openscript committed Nov 4, 2024
1 parent 875cd8c commit cab3ec3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-birds-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@quassel/backend": patch
---

Enhance docker image
8 changes: 4 additions & 4 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Install dependencies only when needed
FROM docker.io/node:lts-alpine AS deps
FROM docker.io/node:20-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --omit=dev

# Production image, copy all the files and run nest
FROM docker.io/node:lts-alpine AS runner
FROM docker.io/node:20-alpine AS runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV=production
ENV PORT=3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=deps /usr/src/app/package.json ../package.json
COPY dist/* .
COPY --from=deps /usr/src/app/package.json ./package.json
COPY dist/ .
RUN chown -R node:node .
USER node
EXPOSE 3000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig, PostgreSqlDriver } from "@mikro-orm/postgresql";
import { Migrator } from "@mikro-orm/migrations";
import { TsMorphMetadataProvider } from "@mikro-orm/reflection";
import { SeedManager } from "@mikro-orm/seeder";
import { configuration } from "./config/configuration";
import { configuration } from "./src/config/configuration";

const c = configuration();

Expand Down
6 changes: 5 additions & 1 deletion docs/examples/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ services:
- database
environment:
LANG: C.UTF-8
DATABASE_URL: "postgresql://postgres:secret@database/quassel_production"
CORS_ORIGIN: https://test.example.com
SESSION_SECRET: secret
SESSION_SALT: salt
DATABASE_HOST: database
DATABASE_PASSWORD: secret
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "traefik.enable=true"
Expand Down
4 changes: 4 additions & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ The following sources were used:
sed -i "s/example.com/example.com/g" docker-compose.yaml
```

1. Set environment variables in `docker-compose.yaml`:
- `SESSION_SECRET` to a 32byte random hex string with `openssl rand -hex 32`
- `SESSION_SALT` to a 8byte random hex string with `openssl rand -hex 8`
- `DATABASE_PASSWORD` set a more secure password for the database
1. Change contact email for SSL certificates in `traefik.yaml`
1. Configure the following environment variables in `docker-compose.yaml`:
- **todo**
Expand Down

0 comments on commit cab3ec3

Please sign in to comment.