Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
node_modules
npm-debug.log
*/node_modules
dist
build
.git
.gitignore
README.md
*.md
.env
.env.local
.env.production
.env.*
coverage
.DS_Store
*.log
client/dist
client/build
client/functions
client/public
client/src
client/*.html
client/*.json
client/*.ts
client/*.js
client/wrangler.toml
server/dist
bun.lock
compose.yml
shell.nix
CLAUDE.local.md
biome.jsonc
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:20 AS builder
WORKDIR /app

COPY package*.json ./
COPY common/package*.json common/
COPY server/package*.json server/
RUN npm ci

COPY common ./common
COPY server ./server
RUN npm run build:server

FROM node:20-slim
WORKDIR /app

RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/server/dist ./server/dist
COPY --from=builder /app/server/package*.json ./server/
COPY --from=builder /app/server/prisma ./server/prisma
COPY --from=builder /app/package*.json ./

WORKDIR /app/server
RUN npm ci --omit=dev

RUN npx prisma generate

WORKDIR /app

ENV NODE_ENV=production \
PORT=3000
EXPOSE 3000

CMD ["npm", "run", "start:server"]
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<meta property="og:locale" content="ja_JP" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@utokyo_code" />
<meta name="google-site-verification" content="ZdWkLVR4AwMczeCjsJNgGqLrifVHcdwq_Bb0Hphc248" />
</head>

<body style="height: 100%" class="text-gray-600">
Expand Down
27 changes: 27 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# fly.toml app configuration file generated for itsuhima-server on 2025-06-19T13:42:28+09:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'itsuhima-server'
primary_region = 'nrt'

[build]
dockerfile = 'Dockerfile'

[env]
NODE_ENV = 'production'
PORT = '3000'

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

[[vm]]
memory = '512mb'
cpu_kind = 'shared'
cpus = 1
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"dev:server": "cd server && npm run dev",
"dev:client": "cd client && npm run dev",
"dev:db": "docker compose up",
"build:server": "cd server && npm run build",
"start:server": "node server/dist/server/src/main.js",
"check": "npx biome check",
"fix": "npx @biomejs/biome check --fix --unsafe",
"fix:safe": "npx @biomejs/biome check --fix"
Expand Down
6 changes: 3 additions & 3 deletions server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import projectsRoutes from "./routes/projects.js";
export const prisma = new PrismaClient();

const app = express();
const port = 3000;
const port = process.env.PORT || 3000;

const allowedOrigins = process.env.CORS_ALLOW_ORIGINS?.split(",") || [];

Expand All @@ -29,8 +29,8 @@ app.get("/", (req, res) => {

app.use("/projects", projectsRoutes);

app.listen(port, () => {
console.log(`Server listening on port ${port}`);
app.listen(Number(port), "0.0.0.0", () => {
console.log(`Server listening on 0.0.0.0:${port}`);
});

const isProduction = process.env.NODE_ENV === "prod";
Expand Down