File tree Expand file tree Collapse file tree 14 files changed +94
-35
lines changed
Expand file tree Collapse file tree 14 files changed +94
-35
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+ .env *
Original file line number Diff line number Diff line change 1+ SQL_GENERATE_URL = postgres://sql-url
Original file line number Diff line number Diff line change 9797 - uses : oven-sh/setup-bun@v2
9898 - run : bun prepare:deploy:web
9999 - run : test `ls web/.next | wc -l` != 0
100-
101- deploy-test-server :
102- name : Deploy Test (server)
103- runs-on : ubuntu-latest
104- steps :
105- - uses : actions/checkout@v4
106- - uses : oven-sh/setup-bun@v2
107- - run : bun prepare:deploy:server
Original file line number Diff line number Diff line change 1+ name : Deploy
2+ on :
3+ push :
4+ branches :
5+ - main
6+
7+ jobs :
8+ deploy :
9+ name : Deploy Server to Fly.io
10+ runs-on : ubuntu-latest
11+ env :
12+ SQL_GENERATE_URL : ${{ secrets.DATABASE_URL_FOR_PRISMA_SQL_GENERATION }}
13+
14+ steps :
15+ - uses : actions/checkout@v4
16+ - uses : superfly/flyctl-actions/setup-flyctl@master
17+ - run : flyctl deploy --build-arg SQL_GENERATE_URL=$SQL_GENERATE_URL --access-token "${{ secrets.FLY_DEPLOY_TOKEN }}"
Original file line number Diff line number Diff line change 1+ # syntax = docker/dockerfile:1
2+
3+ ARG BUN_VERSION=1.2.2
4+ FROM oven/bun:${BUN_VERSION} AS base
5+ LABEL fly_launch_runtime="Bun/Prisma"
6+ ENV NODE_ENV="production"
7+
8+ # Throw-away build stage to reduce size of final image
9+ FROM base AS build
10+
11+ WORKDIR /build
12+ ARG SQL_GENERATE_URL
13+ RUN test -n "${SQL_GENERATE_URL}"
14+ ENV DATABASE_URL=$SQL_GENERATE_URL
15+ ENV DIRECT_URL=$SQL_GENERATE_URL
16+ COPY . .
17+ RUN --mount=type=cache,target=~/.bun/install bun install --frozen-lockfile --ignore-scripts
18+ RUN cd server; bun prisma generate --sql
19+ RUN cd server; bun run :build
20+
21+
22+ # Final stage for app image
23+ FROM base AS runner
24+ WORKDIR /srv
25+
26+ # Copy built application
27+ COPY --from=build /build/server/target/index.js /srv/index.js
28+ COPY --from=build /build/node_modules/.prisma/client /node_modules/.prisma/client
29+ COPY --from=build /build/node_modules/@img /node_modules/@img
30+
31+ # Start the server by default, this can be overwritten at runtime
32+ EXPOSE 3000
33+ CMD [ "bun" , "run" , "./index.js" ]
Original file line number Diff line number Diff line change @@ -72,6 +72,6 @@ make prepare-deploy-web`
7272
7373server:
7474` ` ` sh
75- make prepare-deploy-server
76- make deploy- server
75+ # prisma がビルド時に DATABASE_URL を要求するため、 root に .env を作って、 .env.sample に従って埋めよう。
76+ bun deploy: server
7777` ` `
Original file line number Diff line number Diff line change 3939 packages =
4040 ( with pkgs ; [
4141 nix # HACK: to fix the side effect of the hack below, installing two instances of nix
42+ flyctl
4243 gnumake
4344 nodejs
4445 biome
Original file line number Diff line number Diff line change 1+ # fly.toml app configuration file generated for coursemate on 2025-03-06T14:33:10+09:00
2+ #
3+ # See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+ #
5+
6+ app = ' coursemate'
7+ primary_region = ' nrt'
8+
9+ [build ]
10+
11+ [deploy ]
12+
13+ [http_service ]
14+ internal_port = 3000
15+ force_https = true
16+ auto_stop_machines = ' stop'
17+ auto_start_machines = true
18+ min_machines_running = 0
19+ processes = [' app' ]
20+
21+ [[vm ]]
22+ memory = ' 512mb'
23+ cpu_kind = ' shared'
24+ cpus = 1
Original file line number Diff line number Diff line change 2828 "watch:server" : " cd server; bun run dev" ,
2929 "seed" : " cd server; bun prisma db seed" ,
3030 "prepare:deploy:web" : " bun install && bun run build:web" ,
31- "prepare:deploy:server" : " bun install" ,
3231 "deploy:web" : " cd web; bun run start --port $PORT" ,
33- "deploy:server" : " cd server; bun run src/index.ts" ,
32+ "deploy:server" : " bun run --env-file=.env :deploy:server" ,
33+ ":deploy:server" : " fly deploy --build-arg SQL_GENERATE_URL=$SQL_GENERATE_URL" ,
34+ "docker:server" : " docker build . --build-arg SQL_GENERATE_URL=$SQL_GENERATE_URL" ,
3435 "dev-db" : " make dev-db" ,
3536 "test" : " make test" ,
3637 "spell" : " bunx cspell --quiet ."
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ node_modules
22
33# WARNING: DELETE THIS IF YOU FIND THIS
44.env
5-
65.env.dev
7- # deprecated, delete /dist if you have one
8- /dist
6+
97/target
You can’t perform that action at this time.
0 commit comments