diff options
| -rw-r--r-- | Dockerfile | 17 | ||||
| -rw-r--r-- | compose.yaml | 2 | ||||
| -rwxr-xr-x | scripts/build-image.sh | 9 | ||||
| -rwxr-xr-x | scripts/container-entrypoint.sh (renamed from scripts/image-startup.sh) | 4 |
4 files changed, 21 insertions, 11 deletions
@@ -1,17 +1,22 @@ -FROM node:slim +FROM node:21-slim as base EXPOSE 3000/tcp WORKDIR /usr/app COPY ./ ./ -SHELL ["/bin/bash", "-c"] - RUN apt update && \ apt install openssl -y && \ apt clean && \ apt autoclean && \ apt autoremove && \ - npm install --ignore-scripts && \ - npm install -g prisma + npm ci --ignore-scripts && \ + npm install -g prisma && \ + prisma generate + +# env vars needed for build not to fail +ARG POSTGRES_PRISMA_URL +ARG POSTGRES_URL_NON_POOLING + +RUN npm run build -ENTRYPOINT ["/bin/bash", "-c", "scripts/image-startup.sh"] +ENTRYPOINT ["/usr/app/scripts/container-entrypoint.sh"] diff --git a/compose.yaml b/compose.yaml index 9f28da6..e0ef111 100644 --- a/compose.yaml +++ b/compose.yaml @@ -16,7 +16,7 @@ services: env_file: - container.env volumes: - - /var/lib/postgresql/data:/var/lib/postgresql/data + - ./postgres-data:/var/lib/postgresql/data healthcheck: test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 5s diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 55ef4a4..95b8acb 100755 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -3,6 +3,13 @@ SPLIIT_APP_NAME=$(node -p -e "require('./package.json').name") 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 diff --git a/scripts/image-startup.sh b/scripts/container-entrypoint.sh index 8a3a90a..364787e 100755 --- a/scripts/image-startup.sh +++ b/scripts/container-entrypoint.sh @@ -1,5 +1,3 @@ #!/bin/bash - prisma migrate deploy -prisma generate -npm run dev +npm run start |
