-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathDockerfile.image-service
66 lines (51 loc) · 2.01 KB
/
Dockerfile.image-service
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
66
FROM registry.access.redhat.com/ubi9/go-toolset:1.21 AS golang
USER 0
## Build
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
ADD . /app
WORKDIR /app
RUN CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /assisted-image-service main.go
## Licenses
RUN go install github.com/google/[email protected]
RUN ${HOME}/go/bin/go-licenses save --save_path /tmp/licenses ./...
# Extract the commit reference from which the image is built
RUN cd /app && git rev-parse --short HEAD > /commit-reference.txt
## Runtime
FROM quay.io/centos/centos:stream9
ARG release=main
ARG version=latest
LABEL com.redhat.component assisted-image-service
LABEL description "Provide RHCOS image customization and serving for assisted-installer"
LABEL summary "Provide RHCOS image customization and serving for assisted-installer"
LABEL io.k8s.description "Provide RHCOS image customization and serving for assisted-installer"
LABEL distribution-scope public
LABEL name assisted-image-service
LABEL release ${release}
LABEL version ${version}
LABEL url https://github.com/openshift/assisted-image-service
LABEL vendor "Red Hat, Inc."
LABEL maintainer "Red Hat"
# Ensure UID can write in data dir (e.g.: when using podman, docker, ...)
# Ensure root group can write in data dir when deployed on OCP
# https://docs.openshift.com/container-platform/4.16/openshift_images/create-images.html#use-uid_create-images
ARG DATA_DIR=/data
ARG UID=1001
ARG GID=0
RUN mkdir $DATA_DIR && chmod 775 $DATA_DIR && chown $UID:$GID /data
VOLUME $DATA_DIR
ENV DATA_DIR=$DATA_DIR
ARG DATA_TEMP_DIR=/data_temp
ARG UID=1001
ARG GID=0
RUN mkdir $DATA_TEMP_DIR && chmod 775 $DATA_TEMP_DIR && chown $UID:$GID /data
VOLUME $DATA_TEMP_DIR
ENV DATA_TEMP_DIR=$DATA_TEMP_DIR
RUN dnf install -y cpio squashfs-tools && dnf clean all
# Copy the commit reference from the builder
COPY --from=golang /commit-reference.txt /commit-reference.txt
USER $UID:$GID
COPY --from=golang /tmp/licenses /licenses
COPY --from=golang /assisted-image-service /assisted-image-service
CMD ["/assisted-image-service"]