Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (52 loc) · 2.59 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (52 loc) · 2.59 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
# syntax=docker/dockerfile:1
#
# Public-demo image for wurk.demo.developerz.ai. The demo app is demo/ — a
# Rails 8 app that mounts the Wurk dashboard read-only and runs a producer that
# exercises cron, unique, batch, rate-limited, and failing jobs. One image runs
# either the read-only dashboard (`web`) or the swarm (`worker`), selected by the
# argument to bin/demo-entrypoint.
# ---- Stage 1: build the dashboard SPA (no Node/bun at runtime) ----
FROM oven/bun:1.4.4-slim AS spa
WORKDIR /src
COPY frontend/package.json frontend/bun.lock ./frontend/
RUN cd frontend && bun install --frozen-lockfile
COPY frontend/ ./frontend/
# vite.config.ts's wurk-manifest-generator plugin readFileSync's ../lib/wurk/version.rb
# at build time, so the SPA stage needs it present (was missing → build ENOENT).
COPY lib/wurk/version.rb ./lib/wurk/version.rb
RUN cd frontend && bun run build # → /src/vendor/assets/dashboard
# ---- Stage 2: Ruby runtime ----
FROM ruby:4.0.10-slim-bookworm
# RAILS_ENV=production; the runtime must supply a real SECRET_KEY_BASE (k8s
# secret — see docs/demo-deploy.md). Read-only + demo mode are baked in.
ENV RAILS_ENV=production \
WURK_DEMO=1 \
WURK_WEB_READ_ONLY=1
# libffi-dev is for the `fiddle` gem: it left Ruby's default gems in 4.0, so
# wurk depends on it explicitly (swarm PR_SET_PDEATHSIG) and it builds a native
# extension here — without the headers `bundle install` dies in extconf.
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
build-essential libsqlite3-dev libyaml-dev libffi-dev curl git && \
rm -rf /var/lib/apt/lists/* && \
useradd --create-home --shell /bin/bash wurk
WORKDIR /wurk
COPY . /wurk
# Bring in the SPA bundle built in stage 1.
COPY --from=spa /src/vendor/assets/dashboard /wurk/vendor/assets/dashboard
# Install the demo app's bundle, prepare its DB, then hand the tree to the
# non-root runtime user. Frozen: install exactly demo/Gemfile.lock (locked with
# this image's Bundler) or fail — never re-resolve at build time. A version bump
# needs `rake release:relock_demo` first; release:check refuses a stale lock.
WORKDIR /wurk/demo
RUN BUNDLE_FROZEN=1 bundle install --jobs 4 --retry 3 && \
SECRET_KEY_BASE=build bin/rails db:prepare && \
chown -R wurk:wurk /wurk
# The commit this image was built from, read back at /demo/build so deploy-demo
# can tell a rolled-out image from an old pod. After the bundle layers so a new
# commit does not cost a reinstall.
ARG WURK_DEMO_BUILD_SHA=unknown
ENV WURK_DEMO_BUILD_SHA=$WURK_DEMO_BUILD_SHA
USER wurk
EXPOSE 3000 7433
ENTRYPOINT ["/wurk/bin/demo-entrypoint"]
CMD ["web"]