-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 9378b07.
- Loading branch information
Showing
8 changed files
with
173 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ HEREDOC | |
|
||
COPY hydra /usr/bin/hydra | ||
|
||
USER ory | ||
|
||
ENTRYPOINT ["hydra"] | ||
CMD ["serve", "all"] | ||
USER ory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
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 <<HEREDOC | ||
# Add a user/group for Ory with a stable UID + GID: | ||
addgroup --system --gid 500 ory | ||
adduser --system --uid 500 \ | ||
--gecos "Ory User" \ | ||
--home /home/ory \ | ||
--ingroup ory \ | ||
--shell /sbin/nologin \ | ||
ory | ||
|
||
# Create the sqlite directory with ownership to that user and group: | ||
# NOTE: This is required for read/write by SQLite. | ||
install --owner ory --group ory --directory /var/lib/sqlite | ||
|
||
# NOTE: Presumably this was already created by the prior RUN directive | ||
chown -R ory:ory /var/lib/softhsm/tokens | ||
HEREDOC | ||
|
||
COPY --from=build-hydra /usr/bin/hydra /usr/bin/hydra | ||
|
||
# Declare the standard ports used by hydra (4444 for public service endpoint, 4445 for admin service endpoint) | ||
EXPOSE 4444 4445 | ||
|
||
ENTRYPOINT ["hydra"] | ||
CMD ["serve"] | ||
USER ory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# TODO: Remove this file in favor of distroless-static variant: | ||
# https://github.com/ory/hydra/blob/master/.docker/Dockerfile-distroless-static | ||
# However if published to any registry, continue to publish the variant tag but as an alias to `-distroless` tags: | ||
# https://github.com/ory/hydra/pull/3914#pullrequestreview-2527315326 | ||
|
||
FROM alpine:3.20 AS base-files | ||
|
||
RUN <<HEREDOC | ||
apk upgrade --no-cache | ||
apk add --no-cache --upgrade ca-certificates | ||
|
||
# Add a user/group for Ory with a stable UID + GID: | ||
# NOTE: This only appears relevant for supporting hydra as non-root, otherwise unnecessary. | ||
addgroup --system --gid 500 ory | ||
adduser --system --uid 500 \ | ||
--gecos "Ory User" \ | ||
--home /home/ory \ | ||
--ingroup ory \ | ||
--shell /sbin/nologin \ | ||
ory | ||
|
||
# Create the sqlite directory with ownership to that user and group: | ||
# NOTE: This is required for read/write by SQLite. | ||
# - Path may be a default value somewhere, or only explicitly provided via DSN? | ||
# - Owner/Group is only relevant to permissions allowing the hydra process to read/write to the location. | ||
install --owner ory --group ory --directory /var/lib/sqlite | ||
HEREDOC | ||
|
||
FROM scratch | ||
COPY --from=base-files /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=base-files /etc/nsswitch.conf /etc/nsswitch.conf | ||
# NOTE: /etc/group and /etc/shadow were not copied over, only user lookup is valid for `USER`: | ||
COPY --from=base-files /etc/passwd /etc/passwd | ||
# NOTE: This COPY defaults to 0:0 for ownership, voiding the requirement conveyed above | ||
COPY --from=base-files /var/lib/sqlite /var/lib/sqlite | ||
|
||
COPY hydra /usr/bin/hydra | ||
|
||
ENTRYPOINT ["hydra"] | ||
CMD ["serve", "all"] | ||
USER ory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# TODO: Remove this file in favor of the main/default Alpine image. The sqlite package is no longer required: | ||
# https://github.com/ory/hydra/blob/master/.docker/Dockerfile-alpine | ||
# However if published to any registry, continue to publish the variant tag but as an alias to standard Alpine image tags: | ||
# https://github.com/ory/hydra/pull/3914#pullrequestreview-2527315326 | ||
|
||
FROM alpine:3.20 | ||
RUN <<HEREDOC | ||
# NOTE: The sqlite package is not required when the later copied hydra binary is built with statically linked sqlite? | ||
apk upgrade --no-cache | ||
apk add --no-cache --upgrade --latest ca-certificates sqlite | ||
|
||
# Add a user/group for Ory with a stable UID + GID: | ||
# NOTE: This only appears relevant for supporting hydra as non-root, otherwise unnecessary. | ||
addgroup --system --gid 500 ory | ||
adduser --system --uid 500 \ | ||
--gecos "Ory User" \ | ||
--home /home/ory \ | ||
--ingroup ory \ | ||
--shell /sbin/nologin \ | ||
ory | ||
|
||
# Create the sqlite directory with ownership to that user and group: | ||
# NOTE: This is required for read/write by SQLite. | ||
# - Path may be a default value somewhere, or only explicitly provided via DSN? | ||
# - Owner/Group is only relevant to permissions allowing the hydra process to read/write to the location. | ||
install --owner ory --group ory --directory /var/lib/sqlite | ||
HEREDOC | ||
|
||
COPY hydra /usr/bin/hydra | ||
|
||
# Declare the standard ports used by Hydra (4444 for public service endpoint, 4445 for admin service endpoint) | ||
EXPOSE 4444 4445 | ||
|
||
ENTRYPOINT ["hydra"] | ||
CMD ["serve"] | ||
USER ory |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters