Skip to content

Commit 98973ad

Browse files
authored
Merge pull request #8 from arunavo4/ray/test-code-and-migrate-ci-to-bun
Switch Dockerfile to Bun
2 parents b09cabd + f6b5df4 commit 98973ad

File tree

1 file changed

+19
-59
lines changed

1 file changed

+19
-59
lines changed

Dockerfile

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,46 @@
11
# syntax=docker/dockerfile:1.4
22

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
244
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
266

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
2911

30-
COPY --from=deps /app/node_modules ./node_modules
12+
# ----------------------------
13+
FROM deps AS builder
3114
COPY . .
32-
33-
RUN pnpm build
34-
# Compile TypeScript scripts to JavaScript
15+
RUN bun run build
3516
RUN mkdir -p dist/scripts && \
3617
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"); \
3819
done
3920

40-
# -----------------------------------
21+
# ----------------------------
4122
FROM deps AS pruner
42-
WORKDIR /app
23+
RUN bun install --production --frozen-lockfile
4324

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+
# ----------------------------
4926
FROM base AS runner
5027
WORKDIR /app
51-
52-
# Only copy production node_modules and built output
5328
COPY --from=pruner /app/node_modules ./node_modules
5429
COPY --from=builder /app/dist ./dist
5530
COPY --from=builder /app/package.json ./package.json
5631
COPY --from=builder /app/docker-entrypoint.sh ./docker-entrypoint.sh
5732
COPY --from=builder /app/scripts ./scripts
58-
COPY --from=builder /app/data ./data
5933

6034
ENV NODE_ENV=production
6135
ENV HOST=0.0.0.0
6236
ENV PORT=4321
6337
ENV DATABASE_URL=file:data/gitea-mirror.db
6438

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
8044

8145
USER gitea-mirror
8246

@@ -86,8 +50,4 @@ EXPOSE 4321
8650
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
8751
CMD wget --no-verbose --tries=1 --spider http://localhost:4321/ || exit 1
8852

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

Comments
 (0)