1
1
# syntax=docker/dockerfile:1.4
2
2
3
- FROM node:lts-alpine AS base
4
- ENV PNPM_HOME=/usr/local/bin
5
- ENV PATH=$PNPM_HOME:$PATH
6
- RUN apk add --no-cache libc6-compat
7
-
8
- # -----------------------------------
9
- FROM base AS deps
10
- WORKDIR /app
11
- RUN apk add --no-cache python3 make g++ gcc
12
-
13
- RUN --mount=type=cache,target=/root/.npm \
14
- corepack enable && corepack prepare pnpm@latest --activate
15
-
16
- COPY package.json pnpm-lock.yaml* ./
17
-
18
- # Full dev install
19
- RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
20
- pnpm install --frozen-lockfile
21
-
22
- # -----------------------------------
23
- FROM base AS builder
3
+ FROM oven/bun:1.2.9-alpine AS base
24
4
WORKDIR /app
25
- RUN apk add --no-cache python3 make g++ gcc
5
+ RUN apk add --no-cache libc6-compat python3 make g++ gcc wget sqlite
26
6
27
- RUN --mount=type=cache,target=/root/.npm \
28
- corepack enable && corepack prepare pnpm@latest --activate
7
+ # ----------------------------
8
+ FROM base AS deps
9
+ COPY package.json bun.lockb* ./
10
+ RUN bun install --frozen-lockfile
29
11
30
- COPY --from=deps /app/node_modules ./node_modules
12
+ # ----------------------------
13
+ FROM deps AS builder
31
14
COPY . .
32
-
33
- RUN pnpm build
34
- # Compile TypeScript scripts to JavaScript
15
+ RUN bun run build
35
16
RUN mkdir -p dist/scripts && \
36
17
for script in scripts/*.ts; do \
37
- node_modules/.bin/tsc --outDir dist/scripts --module commonjs -- target es2020 --esModuleInterop $ script || true ; \
18
+ bun build "$script" --target=bun --outfile=dist/scripts/$(basename "${ script%.ts}.js" ) ; \
38
19
done
39
20
40
- # -----------------------------------
21
+ # ----------------------------
41
22
FROM deps AS pruner
42
- WORKDIR /app
23
+ RUN bun install --production --frozen-lockfile
43
24
44
- # Prune dev dependencies and just keep the production bits
45
- RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
46
- pnpm prune --prod
47
-
48
- # -----------------------------------
25
+ # ----------------------------
49
26
FROM base AS runner
50
27
WORKDIR /app
51
-
52
- # Only copy production node_modules and built output
53
28
COPY --from=pruner /app/node_modules ./node_modules
54
29
COPY --from=builder /app/dist ./dist
55
30
COPY --from=builder /app/package.json ./package.json
56
31
COPY --from=builder /app/docker-entrypoint.sh ./docker-entrypoint.sh
57
32
COPY --from=builder /app/scripts ./scripts
58
- COPY --from=builder /app/data ./data
59
33
60
34
ENV NODE_ENV=production
61
35
ENV HOST=0.0.0.0
62
36
ENV PORT=4321
63
37
ENV DATABASE_URL=file:data/gitea-mirror.db
64
38
65
- # Make entrypoint executable
66
- RUN chmod +x /app/docker-entrypoint.sh
67
-
68
- ENTRYPOINT ["/app/docker-entrypoint.sh" ]
69
-
70
- RUN apk add --no-cache wget sqlite && \
71
- mkdir -p /app/data && \
72
- addgroup --system --gid 1001 nodejs && \
73
- adduser --system --uid 1001 gitea-mirror && \
74
- chown -R gitea-mirror:nodejs /app/data
75
-
76
- COPY --from=builder --chown=gitea-mirror:nodejs /app/dist ./dist
77
- COPY --from=pruner --chown=gitea-mirror:nodejs /app/node_modules ./node_modules
78
- COPY --from=builder --chown=gitea-mirror:nodejs /app/package.json ./package.json
79
- COPY --from=builder --chown=gitea-mirror:nodejs /app/scripts ./scripts
39
+ RUN chmod +x ./docker-entrypoint.sh && \
40
+ mkdir -p /app/data && \
41
+ addgroup --system --gid 1001 nodejs && \
42
+ adduser --system --uid 1001 gitea-mirror && \
43
+ chown -R gitea-mirror:nodejs /app/data
80
44
81
45
USER gitea-mirror
82
46
@@ -86,8 +50,4 @@ EXPOSE 4321
86
50
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
87
51
CMD wget --no-verbose --tries=1 --spider http://localhost:4321/ || exit 1
88
52
89
- # Create a startup script that initializes the database before starting the application
90
- COPY --from=builder --chown=gitea-mirror:nodejs /app/docker-entrypoint.sh ./docker-entrypoint.sh
91
- RUN chmod +x ./docker-entrypoint.sh
92
-
93
- CMD ["./docker-entrypoint.sh" ]
53
+ ENTRYPOINT ["./docker-entrypoint.sh" ]
0 commit comments