Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (58 loc) · 2.56 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (58 loc) · 2.56 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
# syntax=docker/dockerfile:1
#
# Hardened Wolfi-based build for lago-api, and the only one. Every
# downstream build — staging, production and the OSS release — targets
# this file. The Debian-based `Dockerfile.legacy` it replaced is gone.
#
# Consumes two apko-built bases from https://github.com/getlago/lago-packages.
# Both are public, multi-arch and cosign-signed, so building this file needs no
# registry credentials:
# - ghcr.io/getlago/lago-api-build:latest — ruby-4-dev, rust, build-base, node
# - ghcr.io/getlago/lago-api-base:latest — ruby-4, jemalloc, libpq, pdfcpu, git
#
# The bases carry no shell history, no apt, no distro cruft; every package
# has an SBOM and is signed. This Dockerfile just bundles gems and copies code.
ARG BUILD_IMAGE=ghcr.io/getlago/lago-api-build:latest
ARG RUNTIME_IMAGE=ghcr.io/getlago/lago-api-base:latest
FROM ${BUILD_IMAGE} AS build
ARG BUNDLE_WITH
ARG BUNDLER_VERSION=4.0.19
USER root
WORKDIR /app
ENV BUNDLE_WITH=${BUNDLE_WITH:-}
ENV BUNDLE_WITHOUT="development test"
ENV BUNDLE_PATH=/usr/local/bundle
ENV GEM_HOME=/usr/local/bundle
ENV PATH=/usr/local/bundle/bin:${PATH}
COPY Gemfile Gemfile.lock ./
RUN gem install bundler --no-document -v "${BUNDLER_VERSION}"
RUN --mount=type=secret,id=BUNDLE_GEMS__CONTRIBSYS__COM,env=BUNDLE_GEMS__CONTRIBSYS__COM \
bundle config set --local build.nokogiri --use-system-libraries && \
bundle install --jobs=3 --retry=3
FROM ${RUNTIME_IMAGE}
ARG BUNDLE_WITH
ARG SEGMENT_WRITE_KEY
ARG GOCARDLESS_CLIENT_ID
ARG GOCARDLESS_CLIENT_SECRET
ENV SEGMENT_WRITE_KEY=${SEGMENT_WRITE_KEY}
ENV GOCARDLESS_CLIENT_ID=${GOCARDLESS_CLIENT_ID}
ENV GOCARDLESS_CLIENT_SECRET=${GOCARDLESS_CLIENT_SECRET}
ENV BUNDLE_WITH=${BUNDLE_WITH:-}
ENV BUNDLE_WITHOUT="development test"
ENV BUNDLE_PATH=/usr/local/bundle
ENV GEM_HOME=/usr/local/bundle
ENV PATH=/usr/local/bundle/bin:${PATH}
WORKDIR /app
COPY --from=build --chown=nonroot:nonroot /usr/local/bundle /usr/local/bundle
COPY --chown=nonroot:nonroot . .
USER nonroot
# Explicitly empty, and load-bearing. The runtime base used to set an
# ENTRYPOINT of its own; anything inherited here would turn the `command:` of
# every docker-compose service and the `command` of every k8s container into a
# mere argument of that entrypoint, which start.sh ignores. That is how
# v1.54.0 shipped an image where `migrate` silently booted Puma. The base no
# longer sets one, and this line keeps the contract true regardless of which
# revision of the floating `:latest` base this is built against.
# `ci/docker-boot-contract.sh` asserts it.
ENTRYPOINT []
CMD ["/app/scripts/start.sh"]