From 0f735d2efbd0f70d3862c9ec03c0008135c27ac7 Mon Sep 17 00:00:00 2001 From: nzambello Date: Mon, 7 Aug 2023 13:35:26 +0200 Subject: [PATCH] chore: update dockerfile and deploy stuff --- Dockerfile | 36 +++++++++++++++++++++--------------- start.sh | 18 ++++++++++-------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5abfe2..f09a098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,26 +10,26 @@ RUN apt-get update && apt-get install -y openssl sqlite3 # Install all node_modules, including dev dependencies FROM base as deps -WORKDIR /myapp +WORKDIR /translaite -ADD package.json package-lock.json .npmrc ./ +ADD package.json .npmrc ./ RUN npm install --include=dev # Setup production node_modules FROM base as production-deps -WORKDIR /myapp +WORKDIR /translaite -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json package-lock.json .npmrc ./ +COPY --from=deps /translaite/node_modules /translaite/node_modules +ADD package.json .npmrc ./ RUN npm prune --omit=dev # Build the app FROM base as build -WORKDIR /myapp +WORKDIR /translaite -COPY --from=deps /myapp/node_modules /myapp/node_modules +COPY --from=deps /translaite/node_modules /translaite/node_modules ADD prisma . RUN npx prisma generate @@ -43,19 +43,25 @@ FROM base ENV DATABASE_URL=file:/data/sqlite.db ENV PORT="8080" ENV NODE_ENV="production" +ENV SESSION_SECRET="${SESSION_SECRET:-8d17b3e56ceaf651e8763db9a80fc7f6}" +ENV ALLOW_USER_SIGNUP=0 # add shortcut for connecting to database CLI RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli -WORKDIR /myapp +WORKDIR /translaite -COPY --from=production-deps /myapp/node_modules /myapp/node_modules -COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma +COPY --from=production-deps /translaite/node_modules /translaite/node_modules +COPY --from=build /translaite/node_modules/.prisma /translaite/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 -COPY --from=build /myapp/prisma /myapp/prisma +COPY --from=build /translaite/build /translaite/build +COPY --from=build /translaite/public /translaite/public +COPY --from=build /translaite/package.json /translaite/package.json +COPY --from=build /translaite/start.sh /translaite/start.sh +COPY --from=build /translaite/prisma /translaite/prisma + +RUN chmod +x start.sh ENTRYPOINT [ "./start.sh" ] + +EXPOSE 8080 diff --git a/start.sh b/start.sh index 4488fd1..f4b02a8 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,6 @@ -#!/bin/sh -ex +#!/bin/sh + +set -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 @@ -6,12 +8,12 @@ # Learn more: https://community.fly.io/t/sqlite-not-getting-setup-properly/4386 # allocate swap space -fallocate -l 512M /swapfile -chmod 0600 /swapfile -mkswap /swapfile -echo 10 > /proc/sys/vm/swappiness -swapon /swapfile -echo 1 > /proc/sys/vm/overcommit_memory +# fallocate -l 512M /swapfile +# chmod 0600 /swapfile +# mkswap /swapfile +# echo 10 > /proc/sys/vm/swappiness +# swapon /swapfile +# echo 1 > /proc/sys/vm/overcommit_memory npx prisma migrate deploy -npm run start +yarn start