-
Notifications
You must be signed in to change notification settings - Fork 42
/
Dockerfile.online
89 lines (66 loc) · 2.94 KB
/
Dockerfile.online
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
ARG RELEASE_VERSION=${RELEASE_VERSION}
ARG EE_BASE_IMAGE=${EE_BASE_IMAGE}
ARG EE_BUILDER_IMAGE=${EE_BUILDER_IMAGE}
# Create Go CLI
FROM registry.redhat.io/ubi8:latest AS cli
# Need to duplicate these, otherwise they won't be available to the stage
ARG RELEASE_VERSION=${RELEASE_VERSION}
ARG QUAY_IMAGE=${QUAY_IMAGE}
ARG EE_IMAGE=${EE_IMAGE}
ARG REDIS_IMAGE=${REDIS_IMAGE}
ARG PAUSE_IMAGE=${PAUSE_IMAGE}
ARG SQLITE_IMAGE=${SQLITE_IMAGE}
ENV GOROOT=/usr/local/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# Get Go binary
RUN curl -o go1.21.13.linux-amd64.tar.gz https://dl.google.com/go/go1.21.13.linux-amd64.tar.gz
RUN tar -xzf go1.21.13.linux-amd64.tar.gz &&\
mv go /usr/local
COPY . /cli
WORKDIR /cli
# Create CLI
ENV RELEASE_VERSION=${RELEASE_VERSION}
ENV EE_IMAGE=${EE_IMAGE}
ENV QUAY_IMAGE=${QUAY_IMAGE}
ENV REDIS_IMAGE=${REDIS_IMAGE}
ENV PAUSE_IMAGE=${PAUSE_IMAGE}
ENV SQLITE_IMAGE=${SQLITE_IMAGE}
RUN go build -v \
-ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.sqliteImage=${SQLITE_IMAGE}" \
-o mirror-registry
# Create Ansible Execution Environment
FROM $EE_BASE_IMAGE as galaxy
ARG ANSIBLE_GALAXY_CLI_COLLECTION_OPTS=
USER root
ADD ansible-runner/context/_build /build
WORKDIR /build
RUN ansible-galaxy role install -r requirements.yml --roles-path /usr/share/ansible/roles
RUN ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path /usr/share/ansible/collections
FROM $EE_BUILDER_IMAGE as builder
COPY --from=galaxy /usr/share/ansible /usr/share/ansible
RUN ansible-builder introspect --sanitize --write-bindep=/tmp/src/bindep.txt --write-pip=/tmp/src/requirements.txt
RUN assemble
FROM $EE_BASE_IMAGE as ansible
USER root
COPY --from=galaxy /usr/share/ansible /usr/share/ansible
COPY --from=builder /output/ /output/
RUN /output/install-from-bindep && rm -rf /output/wheels
COPY ansible-runner/context/app /runner
# Install sqlite cli
FROM registry.access.redhat.com/ubi8-minimal as sqlite-cli
RUN microdnf update -y && \
microdnf install sqlite sqlite-devel -y && \
microdnf clean all
# Create mirror registry archive
FROM registry.redhat.io/ubi8:latest AS build
# Import and archive image dependencies
COPY --from=ansible / /ansible
RUN tar -cvf execution-environment.tar -C /ansible .
COPY --from=cli /cli/mirror-registry .
COPY --from=sqlite-cli / /sqlite3
RUN tar -cvf sqlite3.tar -C /sqlite3 .
# Bundle mirror registry archive
RUN tar -czvf mirror-registry.tar.gz execution-environment.tar mirror-registry sqlite3.tar
# Extract bundle to final release image
FROM registry.redhat.io/ubi8:latest AS release
COPY --from=build mirror-registry.tar.gz mirror-registry.tar.gz