Skip to content

Commit 027cc38

Browse files
committed
Merge remote-tracking branch 'origin/main' into migrate
2 parents f128f64 + 530ba3c commit 027cc38

32 files changed

+357
-255
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env*

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SQL_GENERATE_URL=postgres://sql-url

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,3 @@ jobs:
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

.github/workflows/deploy.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 }}"

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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" ]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ make prepare-deploy-web`
7272

7373
server:
7474
```sh
75-
make prepare-deploy-server
76-
make deploy-server
75+
# prisma がビルド時に DATABASE_URL を要求するため、 root に .env を作って、 .env.sample に従って埋めよう。
76+
bun deploy:server
7777
```

bun.lock

Lines changed: 80 additions & 57 deletions
Large diffs are not rendered by default.

common/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"name": "common",
3+
"private": true,
4+
"version": "1.0.0",
35
"type": "module",
46
"devDependencies": {
57
"@types/bun": "latest"

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
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

fly.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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

0 commit comments

Comments
 (0)