-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (65 loc) · 3.48 KB
/
Dockerfile
File metadata and controls
84 lines (65 loc) · 3.48 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
84
# ── Stage: build-core ────────────────────────────────────────────────────────
# Clones mesahub-core and builds the Go binary from source.
# The Go module lives in server/ subdirectory — go install doesn't work.
# Override MESAHUB_CORE_VERSION at build time to pin a specific commit/tag:
# docker build --build-arg MESAHUB_CORE_VERSION=main .
FROM golang:1.24-alpine AS build-core
RUN apk add --no-cache gcc musl-dev sqlite-dev git
ARG MESAHUB_CORE_VERSION=trunk
RUN git clone --depth 1 --branch ${MESAHUB_CORE_VERSION} \
https://github.com/0xdps/mesahub-core.git /mesahub-core
WORKDIR /mesahub-core/server
RUN CGO_ENABLED=1 GOOS=linux go build -o /go/bin/mesahub-server ./cmd/server
# ── Stage: build-backend ──────────────────────────────────────────────────────
FROM node:22-alpine AS build-backend
WORKDIR /app
RUN npm install -g pnpm
# Build the shared emails package first (backend depends on it via file:../emails)
COPY services/emails/package.json ./emails/package.json
RUN cd emails && pnpm install
COPY services/emails/ ./emails/
RUN cd emails && pnpm run build
# Now install and build the backend
COPY services/backend/package.json services/backend/pnpm-lock.yaml services/backend/pnpm-workspace.yaml ./backend/
RUN cd backend && pnpm install --frozen-lockfile
COPY services/backend/ ./backend/
RUN cd backend && pnpm run build
# ── Stage: build-admin ────────────────────────────────────────────────────────
FROM node:22-alpine AS build-admin
WORKDIR /app/admin
RUN npm install -g pnpm
COPY services/admin/package.json services/admin/pnpm-lock.yaml services/admin/pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY services/admin/ ./
RUN pnpm exec vite build
# ── Stage: prod (Caddy + Node + Mailpit) ─────────────────────────────────────
FROM caddy:2-alpine AS caddy-bin
FROM node:22-alpine AS prod
COPY --from=caddy-bin /usr/bin/caddy /usr/bin/caddy
RUN apk add --no-cache curl openssl
WORKDIR /app
# mesahub-server (for embedded mode — skipped if MESAHUB_URL points to external)
COPY --from=build-core /go/bin/mesahub-server /usr/local/bin/mesahub-server
RUN mkdir -p /data
VOLUME ["/data"]
# Install Mailpit binary
ARG TARGETARCH
RUN set -e; \
MAILPIT_VERSION="v1.21.5"; \
if [ "$TARGETARCH" = "arm64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \
curl -fsSL "https://github.com/axllent/mailpit/releases/download/${MAILPIT_VERSION}/mailpit-linux-${ARCH}.tar.gz" \
| tar -xz -C /usr/local/bin mailpit; \
chmod +x /usr/local/bin/mailpit
RUN mkdir -p /usr/share/caddy
# Backend runtime (emails dist is at ../emails relative to backend, per file: dep symlink)
COPY --from=build-backend /app/emails/dist ./emails/dist
COPY --from=build-backend /app/emails/package.json ./emails/package.json
COPY --from=build-backend /app/backend/node_modules ./backend/node_modules
COPY --from=build-backend /app/backend/dist ./backend/dist
COPY services/backend/package.json ./backend/
# Admin static files
COPY --from=build-admin /app/admin/dist /usr/share/caddy
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh
EXPOSE 80
CMD ["/app/start.sh"]