Skip to content

Commit

Permalink
fly.io stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
bastipnt committed Dec 12, 2024
1 parent ade9adb commit 7a14c47
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
**/*.sln
**/*.sw?

**/packages/backend/dbschema/edgeql-js
# **/packages/backend/dbschema/edgeql-js

# flyctl launch added from node_modules/tailwindcss/stubs/.gitignore
!node_modules/tailwindcss/stubs/**/*
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/deploy.yml

This file was deleted.

33 changes: 17 additions & 16 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# 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 }}
# Tmp disabled
# 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 }}
23 changes: 17 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,39 @@ RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY packages/backend/package.json bun.lockb /temp/prod/
COPY package.json bun.lockb /temp/prod/
COPY packages/backend/package.json /temp/prod/packages/backend/
COPY packages/frontend/package.json /temp/prod/packages/frontend/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# FROM base AS generate_edgeql
# COPY packages/backend/edgedb.toml .
# COPY packages/backend/dbschema .
# RUN --mount=type=secret,id=EDGEDB_DSN \
# EDGEDB_DSN="$(cat /run/secrets/EDGEDB_DSN)" bunx edgedb migrate --dsn=$EDGEDB_DSN
# RUN bunx @edgedb/generate edgeql-js

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
# COPY --from=generate_edgeql /usr/src/app/dbschema/edgeql-js packages/backend/dbschema/

# [optional] tests & build
ENV NODE_ENV=production
RUN bun --filter '*' build
ENV VITE_BACKEND_URL=tracking-survey.bastipnt.de
RUN cd /usr/src/app/packages/backend && bun run build
RUN cd /usr/src/app/packages/frontend && bun run build

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/packages/backend/build/server .
COPY --from=prerelease /usr/src/app/packages/backend/package.json .
COPY --from=prerelease /usr/src/app/packages/frontend/dist .
COPY --from=prerelease /usr/src/app/packages/frontend/dist dist

# run the app
USER bun

EXPOSE 3000/tcp
ENTRYPOINT [ "server" ]
EXPOSE 3000
CMD [ "./server" ]
18 changes: 9 additions & 9 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ app = 'tracking-survey'
[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
memory = '1gb'
cpu_kind = 'shared'
cpus = 1

0 comments on commit 7a14c47

Please sign in to comment.