From 9087484209ed1314476027ac856afab97423ab22 Mon Sep 17 00:00:00 2001 From: Anatoli Nicolae Date: Wed, 20 Mar 2024 16:06:18 +0100 Subject: [PATCH] Decouple Docker entrypoint and fix schema issues Signed-off-by: Anatoli Nicolae --- Dockerfile | 9 +++++---- docker-entrypoint.sh | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 259d515c2..b9e853f96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ WORKDIR /myapp COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD /app/database/schema.prisma . +ADD /app/database/schema.prisma ./app/database/schema.prisma RUN npx prisma generate ADD . . @@ -47,11 +47,12 @@ 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/app/database/schema.prisma /myapp/app/database/schema.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 -RUN chmod +x /myapp/start.sh +COPY --from=build /myapp/docker-entrypoint.sh /myapp/docker-entrypoint.sh +RUN chmod +x /myapp/docker-entrypoint.sh -ENTRYPOINT [ "./start.sh" ] +ENTRYPOINT [ "./docker-entrypoint.sh" ] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 000000000..1d753f816 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/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 + +# Generate schema and deploy +npm run setup:db + +# Start the app +npm run start