forked from quay/mirror-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.online
80 lines (59 loc) · 2.69 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
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 POSTGRES_IMAGE=${POSTGRES_IMAGE}
ARG REDIS_IMAGE=${REDIS_IMAGE}
ARG PAUSE_IMAGE=${PAUSE_IMAGE}
ENV GOROOT=/usr/local/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# Get Go binary
RUN curl -o go1.16.4.linux-amd64.tar.gz https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz
RUN tar -xzf go1.16.4.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 POSTGRES_IMAGE=${POSTGRES_IMAGE}
ENV PAUSE_IMAGE=${PAUSE_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.postgresImage=${POSTGRES_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
# 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 .
# Bundle mirror registry archive
RUN tar -czvf mirror-registry.tar.gz execution-environment.tar mirror-registry
# 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