ory-am/hydra

View on GitHub
.docker/Dockerfile-build

Summary

Maintainability
Test Coverage
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 CGO_ENABLED=1

RUN go mod download

COPY . .
RUN go build -ldflags="-extldflags=-static" -tags sqlite,sqlite_omit_load_extension -o /usr/bin/hydra

#########################

FROM gcr.io/distroless/static-debian12:nonroot AS runner

COPY --from=builder --chown=nonroot:nonroot /var/lib/sqlite /var/lib/sqlite
COPY --from=builder /usr/bin/hydra /usr/bin/hydra

VOLUME /var/lib/sqlite

# Declare the standard ports used by hydra (4444 for public service endpoint, 4445 for admin service endpoint)
EXPOSE 4444 4445

ENTRYPOINT ["hydra"]
CMD ["serve", "all"]