Skip to content

Commit a157e41

Browse files
mirskifaGitHub Enterprise
authored andcommitted
Move chown to COPY to reduce overall image size (#692)
1 parent 4761076 commit a157e41

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

Dockerfile-server

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"
4545
&& go build ./cmd/chkmqhealthy/ \
4646
&& go build ./cmd/chkmqstarted/ \
4747
&& go build ./cmd/runmqdevserver/ \
48+
&& chmod ug+x ./chkmq* ./runmq* \
4849
&& go test -v ./cmd/runmqdevserver/... \
4950
&& go test -v ./cmd/runmqserver/ \
5051
&& go test -v ./cmd/chkmqready/ \
@@ -108,32 +109,28 @@ LABEL summary="IBM MQ Advanced Server" \
108109
io.k8s.description="Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises" \
109110
base-image=$BASE_IMAGE \
110111
base-image-release=$BASE_TAG
111-
COPY --from=mq-redux /opt/mqm-redux/ /opt/mqm/
112-
COPY setup-image.sh /usr/local/bin/
113-
COPY install-mq-server-prereqs.sh /usr/local/bin/
112+
COPY --chown=1001:root --from=mq-redux /opt/mqm-redux/ /opt/mqm/
113+
COPY --chown=1001:root setup-image.sh /usr/local/bin/
114+
COPY --chown=1001:root install-mq-server-prereqs.sh /usr/local/bin/
114115
RUN env \
115116
&& chmod u+x /usr/local/bin/install-*.sh \
116117
&& chmod u+x /usr/local/bin/setup-image.sh \
117118
&& install-mq-server-prereqs.sh \
118119
&& setup-image.sh \
119-
&& /opt/mqm/bin/security/amqpamcf \
120-
&& chown -R 1001:root /opt/mqm/*
121-
COPY --from=builder $GO_WORKDIR/runmqserver /usr/local/bin/
122-
COPY --from=builder $GO_WORKDIR/chkmq* /usr/local/bin/
120+
&& /opt/mqm/bin/security/amqpamcf
121+
COPY --chown=1001:root --from=builder $GO_WORKDIR/runmqserver /usr/local/bin/
122+
COPY --chown=1001:root --from=builder $GO_WORKDIR/chkmq* /usr/local/bin/
123123
COPY ha/native-ha.ini.tpl /etc/mqm/native-ha.ini.tpl
124124
# Copy web XML files
125-
COPY web /etc/mqm/web
126-
COPY etc/mqm/*.tpl /etc/mqm/
125+
COPY --chown=1001:root web /etc/mqm/web
126+
COPY --chown=1001:root etc/mqm/*.tpl /etc/mqm/
127127
RUN ln -s /run/mqwebcontainer.xml /etc/mqm/web/installations/Installation1/servers/mqweb/mqwebcontainer.xml \
128128
&& ln -s /run/tls.xml /etc/mqm/web/installations/Installation1/servers/mqweb/tls.xml \
129129
&& ln -s /run/jvm.options /etc/mqm/web/installations/Installation1/servers/mqweb/configDropins/defaults/jvm.options \
130130
&& ln -s /run/15-tls.mqsc /etc/mqm/15-tls.mqsc \
131-
&& ln -s /run/native-ha.ini /etc/mqm/native-ha.ini
132-
RUN chmod ug+x /usr/local/bin/runmqserver \
133-
&& chown 1001:root /usr/local/bin/*mq* \
134-
&& chmod ug+x /usr/local/bin/chkmq* \
135-
&& chown -R 1001:root /etc/mqm/* \
136-
&& touch /run/termination-log \
131+
&& ln -s /run/native-ha.ini /etc/mqm/native-ha.ini \
132+
&& chown -R 1001:root /etc/mqm/*
133+
RUN touch /run/termination-log \
137134
&& chown 1001:root /run/termination-log \
138135
&& chmod 0660 /run/termination-log \
139136
&& chmod -R g+w /etc/mqm/web \
@@ -181,18 +178,18 @@ LABEL summary="IBM MQ Advanced for Developers Server" \
181178
base-image-release=$BASE_TAG
182179
USER 0
183180
COPY --from=cbuilder /opt/app-root/src/authservice/mqsimpleauth/build/mqsimpleauth.so /opt/mqm/lib64/
184-
COPY etc/mqm/qm-service-component.ini.default /etc/mqm/
185-
COPY --from=builder $GO_WORKDIR/runmqdevserver /usr/local/bin/
181+
COPY --chown=1001:root etc/mqm/qm-service-component.ini.default /etc/mqm/
182+
COPY --chown=1001:root --from=builder $GO_WORKDIR/runmqdevserver /usr/local/bin/
186183
# Copy template files
187-
COPY incubating/mqadvanced-server-dev/*.tpl /etc/mqm/
184+
COPY --chown=1001:root incubating/mqadvanced-server-dev/*.tpl /etc/mqm/
188185
# Copy web XML files for default developer configuration
189-
COPY incubating/mqadvanced-server-dev/web /etc/mqm/web
186+
COPY --chown=1001:root incubating/mqadvanced-server-dev/web /etc/mqm/web
190187
RUN ln -s /run/10-dev.mqsc /etc/mqm/10-dev.mqsc \
191-
&& ln -s /run/20-dev-tls.mqsc /etc/mqm/20-dev-tls.mqsc
192-
RUN chown -R 1001:root /etc/mqm/* \
193-
&& chmod -R g+w /etc/mqm/web \
194-
&& chmod +x /usr/local/bin/runmq* \
195-
&& ln -s /run/qm-service-component.ini /etc/mqm/qm-service-component.ini
188+
&& ln -s /run/20-dev-tls.mqsc /etc/mqm/20-dev-tls.mqsc \
189+
&& chown --no-dereference 1001:root /etc/mqm/*.mqsc
190+
RUN chmod -R g+w /etc/mqm/web \
191+
&& ln -s /run/qm-service-component.ini /etc/mqm/qm-service-component.ini \
192+
&& chown --no-dereference 1001:root /etc/mqm/qm-service-component.ini
196193

197194
ENV MQ_DEV=true \
198195
MQ_ENABLE_EMBEDDED_WEB_SERVER=1 \

0 commit comments

Comments
 (0)