Files
EagleCast/Dockerfile
T

78 lines
2.5 KiB
Docker
Raw Normal View History

2026-07-09 10:39:44 -04:00
# Self-contained build for EagleCast. Builds the email-builder and admin
# frontend, compiles the Go backend, and stuffs all static assets into a
# single binary. Used by PaaS platforms like Coolify that build from git.
# (Release builds via goreleaser use Dockerfile.goreleaser instead.)
ARG APP_VERSION=v1.0.0
# ---- email-builder (React) ----
FROM node:22-alpine AS email-builder
WORKDIR /build/email-builder
COPY frontend/email-builder/package.json frontend/email-builder/yarn.lock ./
RUN yarn install --frozen-lockfile
COPY frontend/email-builder/ ./
RUN yarn build
# ---- admin frontend (Vue) ----
FROM node:22-alpine AS frontend
ARG APP_VERSION
WORKDIR /build/frontend
COPY frontend/package.json frontend/yarn.lock ./
2026-07-09 11:02:02 -04:00
# The postinstall hook copies the altcha widget to ../static/public/static.
RUN mkdir -p /build/static/public/static && yarn install --frozen-lockfile
2026-07-09 10:39:44 -04:00
COPY frontend/ ./
COPY --from=email-builder /build/email-builder/dist ./public/static/email-builder
ENV VUE_APP_VERSION=${APP_VERSION}
2026-07-09 11:05:03 -04:00
# Invoke vite directly: the package.json "prebuild" hook runs eslint with
# --ignore-path .gitignore, which isn't present in the build context.
RUN yarn vite build
2026-07-09 10:39:44 -04:00
# ---- backend (Go) ----
FROM golang:1.26-alpine AS backend
ARG APP_VERSION
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
RUN go install github.com/knadh/stuffbin/...@latest
COPY . .
COPY --from=frontend /build/frontend/dist ./frontend/dist
2026-07-09 11:02:02 -04:00
COPY --from=frontend /build/static/public/static/altcha.umd.js ./static/public/static/altcha.umd.js
2026-07-09 10:39:44 -04:00
RUN CGO_ENABLED=0 go build -o eaglecast \
-ldflags="-s -w -X 'main.buildString=${APP_VERSION} (docker)' -X 'main.versionString=${APP_VERSION}'" \
./cmd
RUN /go/bin/stuffbin -a stuff -in eaglecast -out eaglecast \
config.toml.sample \
schema.sql queries:/queries permissions.json \
static/public:/public \
static/email-templates \
frontend/dist:/admin \
i18n:/i18n
# ---- runtime ----
2026-07-09 10:03:32 -04:00
FROM alpine:latest
# Install dependencies
RUN apk --no-cache add ca-certificates tzdata shadow su-exec
# Set the working directory
WORKDIR /eaglecast
# Copy only the necessary files
2026-07-09 10:39:44 -04:00
COPY --from=backend /build/eaglecast .
2026-07-09 10:03:32 -04:00
COPY config.toml.sample config.toml
# Copy the entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
# Make the entrypoint script executable
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose the application port
EXPOSE 9000
# Set the entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]
# Define the command to run the application
CMD ["./eaglecast"]