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