Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM --platform=$BUILDPLATFORM alpine:3 AS certs
RUN apk add --no-cache ca-certificates
ARG ALPINE_IMAGE=alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
FROM --platform=$BUILDPLATFORM $ALPINE_IMAGE AS certs
# Prepare the directories on the build platform so the target stage needs no emulation.
RUN apk add --no-cache ca-certificates && mkdir /runtime-work /runtime-home

FROM alpine:3
FROM $ALPINE_IMAGE
ARG TARGETPLATFORM
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=certs --chown=65534:65534 /runtime-work/ /work/
COPY --from=certs --chown=65534:65534 /runtime-home/ /home/nobody/
COPY $TARGETPLATFORM/flagsmith /usr/local/bin/flagsmith
ENV HOME=/home/nobody
WORKDIR /work
USER 65534:65534
ENTRYPOINT ["flagsmith"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ go build -o flagsmith .
## Docker

```sh
docker run --rm -v "$PWD:/work" -e FLAGSMITH_API_KEY ghcr.io/flagsmith/flagsmith-cli flag list
docker run --rm -v "$PWD:/work:ro" -e FLAGSMITH_API_KEY ghcr.io/flagsmith/flagsmith-cli flag list
```

A container has no keyring, so `flagsmith login` cannot store credentials there — pass `FLAGSMITH_API_KEY` or `FLAGSMITH_ENVIRONMENT_KEY`.

The image runs as an unprivileged user. For a command that writes to `/work`, such as `flagsmith init`, mount the directory read-write and select the user that owns it:

- With rootful Docker and default UID mapping, add `--user "$(id -u):$(id -g)" -e HOME=/tmp` to use your host account.
- With rootless Docker and a directory owned by the daemon user, add `--user 0:0 -e HOME=/tmp`. Container UID and GID 0 map to the host account running the daemon. See [Docker's UID/GID mapping guide](https://docs.docker.com/engine/security/rootless/uid-gid-mapping/).

## Quickstart

```sh
Expand Down
Loading