File tree Expand file tree Collapse file tree 11 files changed +75
-21
lines changed
Expand file tree Collapse file tree 11 files changed +75
-21
lines changed Original file line number Diff line number Diff line change 1+ node_modules
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 1+ # syntax = docker/dockerfile:1
2+
3+ ARG BUN_VERSION=1.2.2
4+ FROM oven/bun:${BUN_VERSION}-slim 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+ # RUN apt-get update -qq && \
11+ # apt-get install --no-install-recommends -y build-essential openssl pkg-config
12+
13+ WORKDIR /build
14+ ARG SQL_GENERATE_URL
15+ ENV DATABASE_URL=$SQL_GENERATE_URL
16+ RUN test -n "${DATABASE_URL}"
17+ COPY . .
18+ RUN --mount=type=cache,target=~/.bun/install bun install --frozen-lockfile --ignore-scripts
19+ RUN cd server; bun prisma generate --sql
20+ RUN cd server; bun run :build
21+
22+
23+ # Final stage for app image
24+ FROM base AS runner
25+ WORKDIR /srv
26+
27+ # Install packages needed for deployment
28+ RUN apt-get update -qq && \
29+ apt-get install --no-install-recommends -y openssl && \
30+ rm -rf /var/lib/apt/lists /var/cache/apt/archives
31+
32+ # Copy built application
33+ COPY --from=build /build/server/target/index.js /srv/index.js
34+
35+ # Start the server by default, this can be overwritten at runtime
36+ EXPOSE 3000
37+ 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 を要求するため
76+ bun --env-file=./.env 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" : " fly deploy --build-arg SQL_GENERATE_URL=$SQL_GENERATE_URL" ,
33+ "docker:server" : " docker build . --build-arg SQL_GENERATE_URL=$SQL_GENERATE_URL" ,
3434 "dev-db" : " make dev-db" ,
3535 "test" : " make test" ,
3636 "spell" : " bunx cspell --quiet ."
Original file line number Diff line number Diff line change @@ -4,6 +4,5 @@ node_modules
44.env
55
66.env.dev
7- # deprecated, delete /dist if you have one
8- /dist
7+ # deprecated, delete /dist and if you have one
98/target
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 66 "scripts" : {
77 "prepare" : " bun --env-file=./.env.dev prisma generate --sql || (echo 'please set DATABASE_URL in server/.env.dev' && exit 1)" ,
88 "dev" : " bun --watch src/index.ts" ,
9- "build" : " tsc" ,
10- "serve" : " bun target/main.js"
9+ "check" : " tsc" ,
10+ "clean" : " rm target -r || true" ,
11+ "build" : " bun clean && bun check && bun run :build" ,
12+ ":build" : " bun build ./src/index.ts --target bun --outfile target/index.js --minify" ,
13+ "serve" : " bun run ./a.js"
1114 },
1215 "prisma" : {
1316 "seed" : " bun src/seeds/seed-test.ts"
You can’t perform that action at this time.
0 commit comments