mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-06 12:36:11 +01:00
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 <sebastien@castiel.me>
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,17 +1,22 @@
|
|||||||
FROM node:slim
|
FROM node:21-slim as base
|
||||||
|
|
||||||
EXPOSE 3000/tcp
|
EXPOSE 3000/tcp
|
||||||
WORKDIR /usr/app
|
WORKDIR /usr/app
|
||||||
COPY ./ ./
|
COPY ./ ./
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
|
||||||
|
|
||||||
RUN apt update && \
|
RUN apt update && \
|
||||||
apt install openssl -y && \
|
apt install openssl -y && \
|
||||||
apt clean && \
|
apt clean && \
|
||||||
apt autoclean && \
|
apt autoclean && \
|
||||||
apt autoremove && \
|
apt autoremove && \
|
||||||
npm install --ignore-scripts && \
|
npm ci --ignore-scripts && \
|
||||||
npm install -g prisma
|
npm install -g prisma && \
|
||||||
|
prisma generate
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/bash", "-c", "scripts/image-startup.sh"]
|
# env vars needed for build not to fail
|
||||||
|
ARG POSTGRES_PRISMA_URL
|
||||||
|
ARG POSTGRES_URL_NON_POOLING
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/app/scripts/container-entrypoint.sh"]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- container.env
|
- container.env
|
||||||
volumes:
|
volumes:
|
||||||
- /var/lib/postgresql/data:/var/lib/postgresql/data
|
- ./postgres-data:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||||
interval: 5s
|
interval: 5s
|
||||||
|
|||||||
@@ -3,6 +3,13 @@
|
|||||||
SPLIIT_APP_NAME=$(node -p -e "require('./package.json').name")
|
SPLIIT_APP_NAME=$(node -p -e "require('./package.json').name")
|
||||||
SPLIIT_VERSION=$(node -p -e "require('./package.json').version")
|
SPLIIT_VERSION=$(node -p -e "require('./package.json').version")
|
||||||
|
|
||||||
docker buildx build --no-cache -t ${SPLIIT_APP_NAME}:${SPLIIT_VERSION} -t ${SPLIIT_APP_NAME}:latest .
|
# we need to set dummy data for POSTGRES env vars in order for build not to fail
|
||||||
|
docker buildx build \
|
||||||
|
--no-cache \
|
||||||
|
--build-arg POSTGRES_PRISMA_URL=postgresql://build:@db \
|
||||||
|
--build-arg POSTGRES_URL_NON_POOLING=postgresql://build:@db \
|
||||||
|
-t ${SPLIIT_APP_NAME}:${SPLIIT_VERSION} \
|
||||||
|
-t ${SPLIIT_APP_NAME}:latest \
|
||||||
|
.
|
||||||
|
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
prisma migrate deploy
|
prisma migrate deploy
|
||||||
prisma generate
|
npm run start
|
||||||
npm run dev
|
|
||||||
Reference in New Issue
Block a user