Skip to content

Commit 9759f61

Browse files
Production target for Dockerfile (#57)
* add production build * add back updates and use slim image * udpate command * ignore scripts * add workdir * fix workdirs * docker image improvements * use .example instead * use dummy data instead * remove unused env var and add comment * fix entrypoints * change name of script and add possibility for different commands * change to safer default for volume * add instructions for the dev docker container * update copy * add empty lines under topics to keep uniformity * most RUN's in a single command * add comment about volumes for dev target * remove dev workflow * remove dev workflow from readme * Prettify README --------- Co-authored-by: Sebastien Castiel <[email protected]>
1 parent d43e731 commit 9759f61

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

Dockerfile

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
FROM node:slim
1+
FROM node:21-slim as base
22

33
EXPOSE 3000/tcp
44
WORKDIR /usr/app
55
COPY ./ ./
66

7-
SHELL ["/bin/bash", "-c"]
8-
97
RUN apt update && \
108
apt install openssl -y && \
119
apt clean && \
1210
apt autoclean && \
1311
apt autoremove && \
14-
npm install --ignore-scripts && \
15-
npm install -g prisma
12+
npm ci --ignore-scripts && \
13+
npm install -g prisma && \
14+
prisma generate
15+
16+
# env vars needed for build not to fail
17+
ARG POSTGRES_PRISMA_URL
18+
ARG POSTGRES_URL_NON_POOLING
19+
20+
RUN npm run build
1621

17-
ENTRYPOINT ["/bin/bash", "-c", "scripts/image-startup.sh"]
22+
ENTRYPOINT ["/usr/app/scripts/container-entrypoint.sh"]

compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
env_file:
1717
- container.env
1818
volumes:
19-
- /var/lib/postgresql/data:/var/lib/postgresql/data
19+
- ./postgres-data:/var/lib/postgresql/data
2020
healthcheck:
2121
test: ['CMD-SHELL', 'pg_isready -U postgres']
2222
interval: 5s

scripts/build-image.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
SPLIIT_APP_NAME=$(node -p -e "require('./package.json').name")
44
SPLIIT_VERSION=$(node -p -e "require('./package.json').version")
55

6-
docker buildx build --no-cache -t ${SPLIIT_APP_NAME}:${SPLIIT_VERSION} -t ${SPLIIT_APP_NAME}:latest .
6+
# we need to set dummy data for POSTGRES env vars in order for build not to fail
7+
docker buildx build \
8+
--no-cache \
9+
--build-arg POSTGRES_PRISMA_URL=postgresql://build:@db \
10+
--build-arg POSTGRES_URL_NON_POOLING=postgresql://build:@db \
11+
-t ${SPLIIT_APP_NAME}:${SPLIIT_VERSION} \
12+
-t ${SPLIIT_APP_NAME}:latest \
13+
.
714

815
docker image prune -f
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/bin/bash
2-
32
prisma migrate deploy
4-
prisma generate
5-
npm run dev
3+
npm run start

0 commit comments

Comments
 (0)