Skip to content

Commit a488bc9

Browse files
authored
Merge pull request #7 from Joker666/develop
Added Dockerfile
2 parents e63a634 + d64412c commit a488bc9

File tree

4 files changed

+85
-3
lines changed

4 files changed

+85
-3
lines changed

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM node:22-alpine AS base
2+
3+
FROM base AS builder
4+
5+
RUN apk add --no-cache gcompat
6+
WORKDIR /app
7+
8+
# Install pnpm
9+
RUN corepack enable && corepack prepare pnpm@latest --activate
10+
11+
COPY package.json pnpm-lock.yaml tsconfig.json src ./
12+
13+
RUN pnpm install --frozen-lockfile && \
14+
pnpm run build && \
15+
pnpm prune --prod
16+
17+
FROM base AS runner
18+
WORKDIR /app
19+
20+
RUN addgroup --system --gid 1001 nodejs
21+
RUN adduser --system --uid 1001 hono
22+
23+
COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules
24+
COPY --from=builder --chown=hono:nodejs /app/dist /app/dist
25+
COPY --from=builder --chown=hono:nodejs /app/package.json /app/package.json
26+
27+
USER hono
28+
EXPOSE 3000
29+
30+
CMD ["node", "/app/dist/index.js"]

docker-compose.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,58 @@
1-
version: "3.8"
21
services:
3-
mysql:
2+
app:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
ports:
7+
- "3000:3000"
8+
environment:
9+
PORT: ${PORT}
10+
LOG_LEVEL: ${LOG_LEVEL}
11+
NODE_ENV: ${NODE_ENV}
12+
SECRET_KEY: ${SECRET_KEY}
13+
14+
DB_HOST: db
15+
DB_USER: ${DB_USER}
16+
DB_PASSWORD: ${DB_PASSWORD}
17+
DB_NAME: ${DB_NAME}
18+
19+
REDIS_HOST: redis
20+
REDIS_PORT: ${REDIS_PORT}
21+
depends_on:
22+
db:
23+
condition: service_healthy
24+
restart: true
25+
redis:
26+
condition: service_healthy
27+
restart: true
28+
29+
db:
430
image: mysql
531
restart: no
632
ports:
733
- "3306:3306"
34+
volumes:
35+
- mysql_data:/var/lib/mysql
836
environment:
937
MYSQL_ROOT_PASSWORD: password
1038
MYSQL_USER: user
1139
MYSQL_PASSWORD: password
1240
MYSQL_DATABASE: db
41+
healthcheck:
42+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
43+
interval: 10s
44+
timeout: 5s
45+
retries: 5
1346

1447
redis:
1548
image: redis
1649
ports:
1750
- "6379:6379"
51+
healthcheck:
52+
test: ["CMD", "redis-cli", "ping"]
53+
interval: 10s
54+
timeout: 5s
55+
retries: 5
56+
57+
volumes:
58+
mysql_data:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"@types/node": "^22.10.10",
2727
"drizzle-kit": "^0.30.2",
2828
"prettier": "3.4.2",
29-
"tsx": "^4.19.2"
29+
"tsx": "^4.19.2",
30+
"typescript": "^5.7.3"
3031
},
3132
"engines": {
3233
"node": ">=20.0.0 <23.0.0"

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)