-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve docker set up #3921
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
715fa08
chore/remove-nsswitch-hosts
polarathene 84eb21a
chore: Revise scratch image
polarathene f8cd2c7
chore: Revise alpine images
polarathene 24f5ba0
chore: Use the same busybox commands with distroless
polarathene 81f378a
chore: Remove redundant `VOLUME` directives
polarathene e066ac1
chore: `Dockerfile-scratch` - Add commentary
polarathene 66f7f01
chore: `Dockerfile-sqlite` - Add commentary
polarathene b86a2a0
chore: `Dockerfile-alpine` - Add commentary
polarathene e3eac04
fix: improve docker set up
aeneasr 7d92281
chore: synchronize workspaces
aeneasr c62ff95
chore: synchronize workspaces
aeneasr f08780e
chore: synchronize workspaces
aeneasr 99d1557
chore: synchronize workspaces
aeneasr e0c0a4a
chore: synchronize workspaces
aeneasr 187922d
chore: synchronize workspaces
aeneasr b51141d
chore: synchronize workspaces
aeneasr 91af1fc
chore: synchronize workspaces
aeneasr e61ad1c
chore: synchronize workspaces
aeneasr c24f156
chore: synchronize workspaces
aeneasr 4449b70
Update .docker/README.md
aeneasr 3691bbe
Update .docker/Dockerfile-local-build
aeneasr 5be3b7d
Update .docker/Dockerfile-test-hsm
aeneasr 4d11798
chore: synchronize workspaces
aeneasr fc235c6
chore: synchronize workspaces
aeneasr 8eb814d
chore: synchronize workspaces
aeneasr 84e3ce0
chore: synchronize workspaces
aeneasr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
FROM alpine:3.20 | ||
|
||
RUN addgroup -S ory; \ | ||
adduser -S ory -G ory -D -H -s /bin/nologin && \ | ||
apk upgrade --no-cache && \ | ||
RUN <<HEREDOC | ||
apk add --no-cache --upgrade ca-certificates | ||
|
||
COPY hydra /usr/bin/hydra | ||
|
||
# set up nsswitch.conf for Go's "netgo" implementation | ||
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 | ||
RUN echo 'hosts: files dns' > /etc/nsswitch.conf | ||
# Add a user/group for nonroot with a stable UID + GID. Values are from nonroot from distroless | ||
# for interoperability with other containers. | ||
addgroup --system --gid 65532 nonroot | ||
adduser --system --uid 65532 \ | ||
--gecos "nonroot User" \ | ||
--home /home/nonroot \ | ||
--ingroup nonroot \ | ||
--shell /sbin/nologin \ | ||
nonroot | ||
HEREDOC | ||
|
||
# By creating the sqlite folder as the ory user, the mounted volume will be owned by ory:ory, which | ||
# is required for read/write of SQLite. | ||
RUN mkdir -p /var/lib/sqlite && \ | ||
chown ory:ory /var/lib/sqlite | ||
COPY hydra /usr/bin/hydra | ||
|
||
USER ory | ||
USER nonroot | ||
|
||
ENTRYPOINT ["hydra"] | ||
CMD ["serve", "all"] |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM golang:1.23-alpine3.21 AS builder | ||
|
||
RUN apk add --no-cache build-base git gcc bash | ||
|
||
WORKDIR /go/src/github.com/ory/hydra | ||
RUN mkdir -p ./internal/httpclient | ||
|
||
COPY go.mod go.sum ./ | ||
COPY internal/httpclient/go.* ./internal/httpclient | ||
|
||
ENV CGO_ENABLED 1 | ||
|
||
RUN go mod download | ||
COPY . . | ||
|
||
RUN go build -tags sqlite,hsm -o /usr/bin/hydra | ||
|
||
ENV HSM_ENABLED=true | ||
ENV HSM_LIBRARY=/usr/lib/softhsm/libsofthsm2.so | ||
ENV HSM_TOKEN_LABEL=hydra | ||
ENV HSM_PIN=1234 | ||
|
||
RUN apk add --no-cache softhsm opensc | ||
RUN pkcs11-tool --module "$HSM_LIBRARY" --slot 0 --init-token --so-pin 0000 --init-pin --pin "$HSM_PIN" --label "$HSM_TOKEN_LABEL" | ||
|
||
FROM builder as test-hsm | ||
|
||
RUN go test -p 1 -failfast -short -tags=sqlite,hsm ./... | ||
|
||
FROM builder AS test-refresh-hsm | ||
|
||
RUN UPDATE_SNAPSHOTS=true go test -p 1 -failfast -short -tags=sqlite,hsm,refresh ./... |
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,6 @@ | ||
This directory contains Dockerfiles for various targets: | ||
|
||
- `Dockerfile-distroless` and `Dockerfile-alpine` are published to Docker Hub | ||
via GoReleaser. | ||
- The other `Dockerfile` variants are intended only for local development and | ||
tests. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
version: 2 | ||
|
||
includes: | ||
- from_url: | ||
url: https://raw.githubusercontent.com/ory/xgoreleaser/master/build.tmpl.yml | ||
|
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While busybox for a shell is convenient, it kinda defeats the purpose of distroless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True - but this really is only for local dev and I do know a few people including myself who sometimes need to exec locally i to the pod to do and test something. It should also point as a warning that this isn’t a prod image