forked from openshift/assisted-image-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.image-service
More file actions
97 lines (77 loc) · 2.72 KB
/
Dockerfile.image-service
File metadata and controls
97 lines (77 loc) · 2.72 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Used to build external packages:
FROM quay.io/centos/centos:stream9 AS packages
# Install the build tools and the required libraries:
RUN \
dnf install -y \
\
gcc \
libtool \
make \
\
libselinux-devel \
libuuid-devel \
libzstd-devel \
lz4-devel \
zlib-devel \
\
&& \
dnf clean all
# Build the packages:
COPY packages /packages
RUN cd /packages && ./build.sh
# Used to build the service:
FROM registry.access.redhat.com/ubi9/go-toolset:1.24 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/go-licenses@v1.6.0
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 the very minimum that we need from the external packages container. That is the 'dump.erofs'
# binary and the compression library (from the 'xz' package) that it needs.
COPY --from=packages /usr/local/lib/liblzma.so.5 /usr/local/lib
COPY --from=packages /usr/local/bin/dump.erofs /usr/local/bin
COPY --from=golang /tmp/licenses /licenses
COPY --from=golang /assisted-image-service /assisted-image-service
CMD ["/assisted-image-service"]