-
Notifications
You must be signed in to change notification settings - Fork 19
/
Dockerfile.kratos
65 lines (43 loc) · 2.22 KB
/
Dockerfile.kratos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2019 Jason Ertel (github.com/jertel).
# Copyright 2020-2024 Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
# https://securityonion.net/license; you may not use this file except in compliance with the
# Elastic License 2.0.
FROM ghcr.io/security-onion-solutions/golang:1.22.6 AS builder
ARG OWNER=ory
ARG VERSION=v1.3.0
RUN addgroup --system ory; \
adduser --system ory --no-create-home --disabled-password --ingroup ory --disabled-login
RUN apt-get update && apt-get upgrade -y && apt-get install -y git gcc bash
RUN mkdir -p /var/lib/sqlite
RUN mkdir -p /go/src/github.com/$OWNER
WORKDIR /go/src/github.com/$OWNER
RUN git clone https://github.com/$OWNER/kratos.git
WORKDIR /go/src/github.com/$OWNER/kratos
RUN git checkout $VERSION
ENV GO111MODULE on
ENV CGO_ENABLED 1
ENV CGO_CPPFLAGS -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600
RUN go mod download
RUN go build -tags sqlite -ldflags="-X 'github.com/ory/kratos/driver/config.Version=${VERSION}' -X 'github.com/ory/kratos/driver/config.Date=$(date -I)' -X 'github.com/ory/kratos/driver/config.Commit=$(git rev-parse --short HEAD)'"
FROM ghcr.io/security-onion-solutions/ubuntu:24.10
RUN apt-get update && apt-get upgrade -y
RUN apt-get update && apt-get install -y ca-certificates
ENV DSN=sqlite:///kratos-data/db.sqlite?_fk=true
ARG UID=928
ARG GID=928
ARG OWNER=ory
RUN groupadd --system kratos --gid "$GID" ; \
useradd --system kratos --no-create-home -g kratos --uid "$UID"
RUN echo "#!/bin/sh" > /start-kratos.sh
RUN echo "kratos -c /kratos-conf/kratos.yaml migrate sql -e --yes >> /kratos-log/kratos-migrate.log 2>&1" >> /start-kratos.sh
RUN echo "chown kratos:kratos /kratos-data/db.sqlite" >> /start-kratos.sh
RUN echo "chmod 600 /kratos-data/db.sqlite" >> /start-kratos.sh
RUN echo "kratos -c /kratos-conf/kratos.yaml serve --sqa-opt-out=true >> /kratos-log/kratos.log 2>&1" >> /start-kratos.sh
RUN chmod a+x /start-kratos.sh
COPY --from=builder /go/src/github.com/$OWNER/kratos/kratos /usr/bin/kratos
COPY --from=builder /go/src/github.com/$OWNER/kratos/.schema /.schema
USER kratos
EXPOSE 4433
EXPOSE 4434
ENTRYPOINT ["/start-kratos.sh"]