From d39dd72eda6036c38a633242628871ea788611fd Mon Sep 17 00:00:00 2001 From: Anatoli Nicolae Date: Sun, 7 Jan 2024 20:32:42 +0100 Subject: [PATCH] Fix start.sh instead of duplicating Dockerfile Signed-off-by: Anatoli Nicolae --- .github/workflows/build.yml | 1 - image.Dockerfile | 56 ------------------------------------- start.sh | 3 +- 3 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 image.Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83966b86c..f9c93f016 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,6 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: image.Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/image.Dockerfile b/image.Dockerfile deleted file mode 100644 index 93cbbda34..000000000 --- a/image.Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# base node image -FROM node:18-bullseye-slim as base - -# set for base and all layer that inherit from it -ENV NODE_ENV production - -# Install openssl for Prisma -RUN apt-get update && apt-get install -y openssl - -# Install all node_modules, including dev dependencies -FROM base as deps - -WORKDIR /myapp - -ADD package.json ./ -RUN npm install --production=false - -# Setup production node_modules -FROM base as production-deps - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json ./ -RUN npm prune --production - -# Build the app -FROM base as build - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules - -ADD /app/database/schema.prisma . -RUN npx prisma generate - -ADD . . -RUN npm run build - -# Finally, build the production image with minimal footprint -FROM base - -ENV PORT="8080" -ENV NODE_ENV="production" - -WORKDIR /myapp - -COPY --from=production-deps /myapp/node_modules /myapp/node_modules -COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma - -COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public -COPY --from=build /myapp/package.json /myapp/package.json -COPY --from=build /myapp/start.sh /myapp/start.sh - -ENTRYPOINT [ "sh", "./start.sh" ] diff --git a/start.sh b/start.sh index 760710193..ba509a8de 100644 --- a/start.sh +++ b/start.sh @@ -1,7 +1,8 @@ +#!/bin/sh -ex + # This file is how Fly starts the server (configured in fly.toml). Before starting # the server though, we need to run any prisma migrations that haven't yet been # run, which is why this file exists in the first place. # Learn more: https://community.fly.io/t/sqlite-not-getting-setup-properly/4386 -set -ex npm run start