Skip to content

Commit cab3ec3

Browse files
committed
chore: enhance docker image
1 parent 875cd8c commit cab3ec3

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

.changeset/many-birds-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@quassel/backend": patch
3+
---
4+
5+
Enhance docker image

apps/backend/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Install dependencies only when needed
2-
FROM docker.io/node:lts-alpine AS deps
2+
FROM docker.io/node:20-alpine AS deps
33
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
44
RUN apk add --no-cache libc6-compat
55
WORKDIR /usr/src/app
66
COPY package*.json ./
77
RUN npm install --omit=dev
88

99
# Production image, copy all the files and run nest
10-
FROM docker.io/node:lts-alpine AS runner
10+
FROM docker.io/node:20-alpine AS runner
1111
RUN apk add --no-cache dumb-init
1212
ENV NODE_ENV=production
1313
ENV PORT=3000
1414
WORKDIR /usr/src/app
1515
COPY --from=deps /usr/src/app/node_modules ./node_modules
16-
COPY --from=deps /usr/src/app/package.json ../package.json
17-
COPY dist/* .
16+
COPY --from=deps /usr/src/app/package.json ./package.json
17+
COPY dist/ .
1818
RUN chown -R node:node .
1919
USER node
2020
EXPOSE 3000

apps/backend/src/mikro-orm.config.ts renamed to apps/backend/mikro-orm.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig, PostgreSqlDriver } from "@mikro-orm/postgresql";
22
import { Migrator } from "@mikro-orm/migrations";
33
import { TsMorphMetadataProvider } from "@mikro-orm/reflection";
44
import { SeedManager } from "@mikro-orm/seeder";
5-
import { configuration } from "./config/configuration";
5+
import { configuration } from "./src/config/configuration";
66

77
const c = configuration();
88

docs/examples/docker-compose.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ services:
3939
- database
4040
environment:
4141
LANG: C.UTF-8
42-
DATABASE_URL: "postgresql://postgres:secret@database/quassel_production"
42+
CORS_ORIGIN: https://test.example.com
43+
SESSION_SECRET: secret
44+
SESSION_SALT: salt
45+
DATABASE_HOST: database
46+
DATABASE_PASSWORD: secret
4347
labels:
4448
- "com.centurylinklabs.watchtower.enable=true"
4549
- "traefik.enable=true"

docs/setup.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ The following sources were used:
106106
sed -i "s/example.com/example.com/g" docker-compose.yaml
107107
```
108108

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

0 commit comments

Comments
 (0)