diff --git a/.docker/Dockerfile-alpine b/.docker/Dockerfile-alpine index 1cc14658ca..72f5e33dde 100644 --- a/.docker/Dockerfile-alpine +++ b/.docker/Dockerfile-alpine @@ -24,6 +24,7 @@ HEREDOC COPY hydra /usr/bin/hydra +USER ory + ENTRYPOINT ["hydra"] CMD ["serve", "all"] -USER ory diff --git a/.docker/Dockerfile-hsm b/.docker/Dockerfile-hsm deleted file mode 100644 index 8c51e3fcda..0000000000 --- a/.docker/Dockerfile-hsm +++ /dev/null @@ -1,88 +0,0 @@ -FROM golang:1.22 AS builder - -WORKDIR /go/src/github.com/ory/hydra - -RUN apt-get update && apt-get upgrade -y &&\ - mkdir -p /var/lib/sqlite &&\ - mkdir -p ./internal/httpclient - -COPY go.mod go.sum ./ -COPY internal/httpclient/go.* ./internal/httpclient - -ENV GO111MODULE on -ENV CGO_ENABLED 1 - -RUN go mod download -COPY . . - -############################### - -FROM builder AS build-hydra -RUN go build -tags sqlite,hsm -o /usr/bin/hydra - -############################### - -FROM builder AS test-hsm -ENV HSM_ENABLED=true -ENV HSM_LIBRARY=/usr/lib/softhsm/libsofthsm2.so -ENV HSM_TOKEN_LABEL=hydra -ENV HSM_PIN=1234 - -RUN apt-get -y install softhsm opensc -RUN pkcs11-tool --module "$HSM_LIBRARY" --slot 0 --init-token --so-pin 0000 --init-pin --pin "$HSM_PIN" --label "$HSM_TOKEN_LABEL" -RUN go test -p 1 -failfast -short -tags=sqlite,hsm ./... - - -FROM builder AS test-refresh-hsm -ENV HSM_ENABLED=true -ENV HSM_LIBRARY=/usr/lib/softhsm/libsofthsm2.so -ENV HSM_TOKEN_LABEL=hydra -ENV HSM_PIN=1234 -ENV UPDATE_SNAPSHOTS=true - -RUN apt-get -y install softhsm opensc -RUN pkcs11-tool --module "$HSM_LIBRARY" --slot 0 --init-token --so-pin 0000 --init-pin --pin "$HSM_PIN" --label "$HSM_TOKEN_LABEL" -RUN go test -p 1 -failfast -short -tags=sqlite,hsm,refresh ./... - -############################### - -FROM gcr.io/distroless/base-nossl-debian12:debug-nonroot AS runner - -ENV HSM_ENABLED=true -ENV HSM_LIBRARY=/usr/lib/softhsm/libsofthsm2.so -ENV HSM_TOKEN_LABEL=hydra -ENV HSM_PIN=1234 - -# NOTE: This is broken already. Even though this image provides a shell, you'd need to configure it with -# `SHELL ["/busybox/sh", "-c"]`, however `apt-get` does not exist either in a distroless image. -# This was original an Alpine image, the refactoring was not verified properly in this commit: -# https://github.com/ory/hydra/commit/c1e1a569621d88365dceee7372ca49ecd119f939#diff-ae54bef08e3587b28ad8e93eb253a9a5cd9ea6f4251977e35b88dc6b42329e25L31 -RUN apt-get -y install softhsm opensc &&\ - pkcs11-tool --module "$HSM_LIBRARY" --slot 0 --init-token --so-pin 0000 --init-pin --pin "$HSM_PIN" --label "$HSM_TOKEN_LABEL" - -RUN < pinniped.dev - + Adopter * Pvotal @@ -835,7 +835,9 @@ make quicktest # regular tests make test -test-resetdb + +# updates all snapshots +make test-refresh # end-to-end tests make e2e @@ -977,10 +979,12 @@ If you wish to check your code changes against any of the docker-compose quickstart files, run: ```shell script -make docker -docker compose -f quickstart.yml up # .... +docker compose -f quickstart.yml up --build # .... ``` +Warning, this will override your local image tag with the latest build and can +lead to unexpected or confusing behavior. + #### Add a new migration 1. `mkdir persistence/sql/src/YYYYMMDD000001_migration_name/` diff --git a/quickstart.yml b/quickstart.yml index c521a273f9..4c229232d8 100644 --- a/quickstart.yml +++ b/quickstart.yml @@ -12,6 +12,9 @@ services: hydra: image: oryd/hydra:v2.2.0 + build: + context: . + dockerfile: .docker/Dockerfile-build ports: - "4444:4444" # Public port - "4445:4445" # Admin port @@ -25,18 +28,25 @@ services: - type: bind source: ./contrib/quickstart/5-min target: /etc/config/hydra + pull_policy: missing environment: - DSN=sqlite:///var/lib/sqlite/db.sqlite?_fk=true restart: unless-stopped + user: 500:500 depends_on: - hydra-migrate networks: - intranet hydra-migrate: image: oryd/hydra:v2.2.0 + build: + context: . + dockerfile: .docker/Dockerfile-build environment: - DSN=sqlite:///var/lib/sqlite/db.sqlite?_fk=true command: migrate -c /etc/config/hydra/hydra.yml sql -e --yes + user: 500:500 + pull_policy: missing volumes: - type: volume source: hydra-sqlite