diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..16ee732 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git +.gitignore + +Dockerfile +.dockerignore + +# gitignore +.vscode +node_modules +/.cache +/build +.env +/local +*.local.* diff --git a/.github/workflows/fly-deploy.yml b/.github/workflows/fly-deploy.yml new file mode 100644 index 0000000..0b4beb5 --- /dev/null +++ b/.github/workflows/fly-deploy.yml @@ -0,0 +1,18 @@ +# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ + +name: Fly Deploy +on: + push: + branches: + - main +jobs: + deploy: + name: Deploy app + runs-on: ubuntu-latest + concurrency: deploy-group # optional: ensure only one action runs at a time + steps: + - uses: actions/checkout@v4 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..abb0dd6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM node:20-slim AS base + +RUN apt-get update +RUN apt-get -y install ca-certificates +RUN corepack use pnpm@9 +RUN corepack enable pnpm + +FROM base AS deps + +WORKDIR /app + +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install + +FROM deps AS prod-deps + +RUN pnpm prune --prod + +FROM deps AS build + +COPY . . + +RUN pnpm build + +FROM base + +ENV NODE_ENV production +ENV PORT 3000 +EXPOSE 3000 + +WORKDIR /app + +COPY --from=prod-deps /app/node_modules /app/node_modules +COPY --from=build /app/build /app/build +# COPY --from=build /app/public /app/public +COPY --from=build /app/package.json /app/package.json +COPY --from=build /app/server.js /app/server.js +COPY --from=build /app/server-utils.js /app/server-utils.js + +CMD [ "pnpm","start" ] diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..773023b --- /dev/null +++ b/fly.toml @@ -0,0 +1,19 @@ +# fly.toml app configuration file generated for polyglotize on 2024-12-23T17:26:18+08:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'polyglotize' +primary_region = 'hkg' +swap_size_mb = 512 + +[http_service] +internal_port = 3000 +force_https = true +auto_stop_machines = 'stop' +auto_start_machines = true + +[[vm]] +cpu_kind = 'shared' +cpus = 1 +memory_mb = 256 diff --git a/package.json b/package.json index 82ea417..dbdd0e6 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "name": "polyglotize", "author": "Samuel Jensen", "license": "MIT", + "engines": { + "node": "20", + "pnpm": "9" + }, "imports": { "#app/*": "./app/*" },