forked from exelearning/exelearning
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (67 loc) · 2.7 KB
/
Dockerfile
File metadata and controls
83 lines (67 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# syntax=docker/dockerfile:1
ARG BUN_VERSION=1.3
ARG VERSION=v0.0.0-alpha
################################################################################
# Base image for reuse
################################################################################
FROM oven/bun:${BUN_VERSION}-alpine AS base
WORKDIR /app
################################################################################
# Dependencies stage - separated for cache efficiency
################################################################################
FROM base AS deps
COPY package.json bun.lock ./
RUN bun install
################################################################################
# Build stage - Compile TypeScript and assets
################################################################################
FROM deps AS builder
COPY tsconfig.json ./
COPY src/ ./src/
COPY scripts/ ./scripts/
COPY views/ ./views/
COPY assets/ ./assets/
COPY public/ ./public/
RUN bun run build:all && \
ls -la public/style/workarea/main.css && \
ls -la dist/ && \
ls -la public/app/app.bundle.js && \
ls -la public/app/yjs/importers.bundle.js && \
ls -la public/app/yjs/exporters.bundle.js && \
ls -la public/bundles/
# Prune dev dependencies after build
RUN rm -rf node_modules && \
bun install --production && \
rm -rf ~/.bun/install/cache
################################################################################
# Production stage
################################################################################
FROM base
ARG VERSION
LABEL maintainer="INTEF <cedec@educacion.gob.es>" \
org.opencontainers.image.title="eXeLearning" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.licenses="AGPL-3.0-or-later"
RUN apk add --no-cache dumb-init
ENV NODE_ENV=production \
APP_ENV=prod \
APP_DEBUG=0
# Copy everything from builder (already has prod node_modules)
COPY --from=builder --chown=bun:bun /app/node_modules ./node_modules
COPY --from=builder --chown=bun:bun /app/dist ./dist
COPY --from=builder --chown=bun:bun /app/public ./public
COPY --from=builder --chown=bun:bun /app/assets ./assets
# Runtime files
COPY --chown=bun:bun package.json ./
COPY --chown=bun:bun views/ ./views/
COPY --chown=bun:bun translations/ ./translations/
COPY --chown=bun:bun docker-entrypoint.sh ./
RUN mkdir -p /app/data /mnt/data && \
chown -R bun:bun /app/data /mnt/data && \
chmod +x docker-entrypoint.sh
USER bun
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget -qO- http://localhost:${APP_PORT:-8080}/healthcheck || exit 1
EXPOSE 8080
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/app/docker-entrypoint.sh"]
CMD ["bun", "run", "dist/index.js"]