Skip to content

Commit c41afb9

Browse files
committed
Convert to single, multi-stage Dockerfile
This allows us to take actually advantage of cached layers from the Docker build. Otherwise, the child image builds were pulling images from DockerHub
1 parent cd2ab0c commit c41afb9

File tree

4 files changed

+87
-89
lines changed

4 files changed

+87
-89
lines changed

.github/workflows/build-container.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,15 @@ jobs:
3737
path: /tmp/.buildx-cache
3838
key: base-${{ matrix.repo }}-buildx-${{ github.sha }}
3939

40-
- name: Generate tag list
41-
id: generate-tag-list
42-
env:
43-
REPO: ${{ matrix.repo }}
44-
run: |
45-
docker_repo=${GITHUB_REPOSITORY/opensciencegrid\/docker-/opensciencegrid/}
46-
echo "::set-output name=taglist::$docker_repo:$REPO"
47-
4840
- name: Set up Docker Buildx
4941
uses: docker/setup-buildx-action@v1
5042

5143
- name: Build Docker image
5244
uses: docker/[email protected]
5345
with:
5446
build-args: BASE_YUM_REPO=${{ matrix.repo }}
55-
tags: "${{ steps.generate-tag-list.outputs.taglist }}"
56-
context: base
57-
cache-to: type=local,dest=/tmp/.buildx-cache
47+
target: base
48+
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
5849

5950
child-image-builds:
6051
name: ${{ matrix.image }}:${{ matrix.repo }} image build
@@ -102,5 +93,5 @@ jobs:
10293
push: True
10394
build-args: BASE_YUM_REPO=${{ matrix.repo }}
10495
tags: "${{ steps.generate-tag-list.outputs.taglist }}"
105-
context: ${{ matrix.image }}
96+
target: ${{ matrix.image }}
10697
cache-from: type=local,src=/tmp/.buildx-cache

Dockerfile

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
########
2+
# base #
3+
########
4+
15
# Specify the opensciencegrid/software-base image tag
26
ARG BASE_YUM_REPO=release
37

4-
FROM opensciencegrid/software-base:$BASE_YUM_REPO
5-
8+
FROM opensciencegrid/software-base:$BASE_YUM_REPO AS base
69
LABEL maintainer "OSG Software <[email protected]>"
710

11+
# previous arg has gone out of scope
812
ARG BASE_YUM_REPO=release
913

1014
# Ensure that the 'condor' UID/GID matches across containers
@@ -31,15 +35,87 @@ RUN if [[ $BASE_YUM_REPO = release ]]; then \
3135
yum clean all && \
3236
rm -rf /var/cache/yum/
3337

34-
COPY etc/osg/image-config.d/* /etc/osg/image-config.d/
35-
COPY etc/condor-ce/config.d/* /usr/share/condor-ce/config.d/
36-
COPY usr/local/bin/* /usr/local/bin/
37-
COPY etc/supervisord.d/* /etc/supervisord.d/
38+
COPY base/etc/osg/image-config.d/* /etc/osg/image-config.d/
39+
COPY base/etc/condor-ce/config.d/* /usr/share/condor-ce/config.d/
40+
COPY base/usr/local/bin/* /usr/local/bin/
41+
COPY base/etc/supervisord.d/* /etc/supervisord.d/
3842

3943
# do the bad thing of overwriting the existing cron job for fetch-crl
40-
ADD etc/cron.d/fetch-crl /etc/cron.d/fetch-crl
44+
ADD base/etc/cron.d/fetch-crl /etc/cron.d/fetch-crl
4145
RUN chmod 644 /etc/cron.d/fetch-crl
4246

4347
# HACK: override condor_ce_jobmetrics from SOFTWARE-4183 until it is released in
4448
# HTCondor-CE.
45-
COPY overrides/condor_ce_jobmetrics /usr/share/condor-ce/condor_ce_jobmetrics
49+
COPY base/overrides/condor_ce_jobmetrics /usr/share/condor-ce/condor_ce_jobmetrics
50+
51+
#################
52+
# osg-ce-condor #
53+
#################
54+
55+
FROM base AS osg-ce-condor
56+
ARG BASE_YUM_REPO=release
57+
LABEL maintainer "OSG Software <[email protected]>"
58+
59+
RUN if [[ $BASE_YUM_REPO = release ]]; then \
60+
yumrepo=osg-upcoming; else \
61+
yumrepo=osg-upcoming-$BASE_YUM_REPO; fi && \
62+
yum install -y --enablerepo=$yumrepo \
63+
osg-ce-condor && \
64+
yum clean all && \
65+
rm -rf /var/cache/yum/
66+
67+
COPY osg-ce-condor/etc/osg/image-config.d/* /etc/osg/image-config.d/
68+
COPY osg-ce-condor/etc/condor/config.d/* /etc/condor/config.d/
69+
COPY osg-ce-condor/usr/local/bin/* /usr/local/bin/
70+
COPY osg-ce-condor/etc/supervisord.d/* /etc/supervisord.d/
71+
72+
#############
73+
# hosted-ce #
74+
#############
75+
76+
FROM base AS hosted-ce
77+
LABEL maintainer "OSG Software <[email protected]>"
78+
79+
ARG BASE_YUM_REPO=release
80+
81+
RUN if [[ $BASE_YUM_REPO = release ]]; then \
82+
yumrepo=osg-upcoming; else \
83+
yumrepo=osg-upcoming-$BASE_YUM_REPO; fi && \
84+
yum install -y --enablerepo=$yumrepo \
85+
osg-ce-bosco && \
86+
rm -rf /var/cache/yum/
87+
88+
COPY hosted-ce/30-remote-site-setup.sh /etc/osg/image-config.d/
89+
90+
# HACK: override condor_ce_jobmetrics from SOFTWARE-4183 until it is released in
91+
# HTCondor-CE.
92+
ADD hosted-ce/overrides/condor_ce_jobmetrics /usr/share/condor-ce/condor_ce_jobmetrics
93+
94+
# Use "ssh -q" in bosco_cluster until the chang has been upstreamed to condor
95+
COPY hosted-ce/overrides/ssh_q.patch /tmp
96+
RUN patch -d / -p0 < /tmp/ssh_q.patch
97+
98+
# Enable bosco_cluster xtrace
99+
COPY hosted-ce/overrides/bosco_cluster_xtrace.patch /tmp
100+
RUN patch -d / -p0 < /tmp/bosco_cluster_xtrace.patch
101+
102+
# HACK: Don't copy over the SSH pub key to the remote side. We set
103+
# this up with the site out of band.
104+
COPY hosted-ce/overrides/skip_key_copy.patch /tmp
105+
RUN patch -d / -p0 < /tmp/skip_key_copy.patch
106+
107+
# Fix Ubuntu20 OS detection (SOFTWARE-4463)
108+
# Can be dropped when HTCONDOR-242 is involved
109+
COPY hosted-ce/overrides/HTCONDOR-242.remote-os-detection.patch /tmp
110+
RUN [[ $BASE_YUM_REPO == 'development' ]] || patch -d / -p0 < /tmp/HTCONDOR-242.remote-os-detection.patch
111+
112+
# Set up Bosco override dir from Git repo (SOFTWARE-3903)
113+
# Expects a Git repo with the following directory structure:
114+
# RESOURCE_NAME_1/
115+
# bosco_override/
116+
# ...
117+
# RESOURCE_NAME_2/
118+
# bosco_override/
119+
# ...
120+
# ...
121+
COPY hosted-ce/bosco-override-setup.sh /usr/local/bin

hosted-ce/Dockerfile

Lines changed: 0 additions & 48 deletions
This file was deleted.

osg-ce-condor/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)