Skip to content

Commit b7411eb

Browse files
authored
chore: use docker buildkit secret (#190)
1 parent e011586 commit b7411eb

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

.drone.star

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def prepublish(config):
174174
"from_secret": "internal_password",
175175
},
176176
"tags": config["internal"],
177-
"build_args_from_env": ["DEB_MIRROR_URL", "DEB_MIRROR_LOGIN", "DEB_MIRROR_PWD"],
177+
"secrets": ["id=mirror-auth\\\\,src=/drone/src/mirror-auth", "id=mirror-url\\\\,src=/drone/src/mirror-url"],
178178
"dockerfile": "%s/Dockerfile.multiarch" % (config["version"]["path"]),
179179
"repo": "registry.drone.owncloud.com/owncloud/%s" % config["repo"],
180180
"registry": "registry.drone.owncloud.com",
@@ -183,15 +183,6 @@ def prepublish(config):
183183
},
184184
"environment": {
185185
"BUILDKIT_NO_CLIENT_TOKEN": True,
186-
"DEB_MIRROR_URL": {
187-
"from_secret": "DEB_MIRROR_URL",
188-
},
189-
"DEB_MIRROR_LOGIN": {
190-
"from_secret": "DEB_MIRROR_LOGIN",
191-
},
192-
"DEB_MIRROR_PWD": {
193-
"from_secret": "DEB_MIRROR_PWD",
194-
},
195186
},
196187
},
197188
]
@@ -268,12 +259,26 @@ def publish(config):
268259
"linux/arm64",
269260
],
270261
"tags": config["version"]["tags"],
271-
"build_args_from_env": ["DEB_MIRROR_URL", "DEB_MIRROR_LOGIN", "DEB_MIRROR_PWD"],
262+
"secrets": ["id=mirror-auth\\\\,src=/drone/src/mirror-auth", "id=mirror-url\\\\,src=/drone/src/mirror-url"],
272263
"dockerfile": "%s/Dockerfile.multiarch" % (config["version"]["path"]),
273264
"repo": "owncloud/%s" % config["repo"],
274265
"context": config["version"]["path"],
275266
"pull_image": False,
276267
},
268+
"when": {
269+
"ref": [
270+
"refs/heads/master",
271+
],
272+
},
273+
},
274+
]
275+
276+
def setup(config):
277+
return [
278+
{
279+
"name": "setup",
280+
"image": "docker.io/owncloudci/alpine",
281+
"failure": "ignore",
277282
"environment": {
278283
"DEB_MIRROR_URL": {
279284
"from_secret": "DEB_MIRROR_URL",
@@ -285,11 +290,10 @@ def publish(config):
285290
"from_secret": "DEB_MIRROR_PWD",
286291
},
287292
},
288-
"when": {
289-
"ref": [
290-
"refs/heads/master",
291-
],
292-
},
293+
"commands": [
294+
'echo "machine $DEB_MIRROR_URL login $DEB_MIRROR_LOGIN password $DEB_MIRROR_PWD" > mirror-auth',
295+
'echo "$DEB_MIRROR_URL" > mirror-url',
296+
],
293297
},
294298
]
295299

@@ -308,6 +312,8 @@ def cleanup(config):
308312
},
309313
},
310314
"commands": [
315+
"rm -f mirror-auth",
316+
"rm -f mirror-url",
311317
"regctl registry login registry.drone.owncloud.com --user $DOCKER_USER --pass $DOCKER_PASSWORD",
312318
"regctl tag rm registry.drone.owncloud.com/owncloud/%s:%s" % (config["repo"], config["internal"]),
313319
],
@@ -367,4 +373,4 @@ def shellcheck(config):
367373
]
368374

369375
def steps(config):
370-
return prepublish(config) + sleep(config) + trivy(config) + publish(config) + cleanup(config)
376+
return setup(config) + prepublish(config) + sleep(config) + trivy(config) + publish(config) + cleanup(config)

v22.04/Dockerfile.multiarch

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ LABEL maintainer="ownCloud GmbH <[email protected]>" \
77
org.opencontainers.image.source="https://github.com/owncloud-docker/php" \
88
org.opencontainers.image.documentation="https://github.com/owncloud-docker/php"
99

10-
ARG DEB_MIRROR_URL
11-
ARG DEB_MIRROR_LOGIN
12-
ARG DEB_MIRROR_PWD
13-
1410
EXPOSE 8080
1511

1612
ENTRYPOINT ["/usr/bin/entrypoint"]
@@ -19,11 +15,11 @@ CMD ["/usr/bin/server"]
1915
# Get the key that the Freexian deb mirror uses for signing
2016
RUN wget http://php.freexian.com/public/archive-key.gpg -O /etc/apt/trusted.gpg.d/freexian-archive-php.gpg
2117
# Get the authentication details for the deb mirror that has been set up to serve the Freexian PHP packages
22-
RUN echo "machine $DEB_MIRROR_URL login $DEB_MIRROR_LOGIN password $DEB_MIRROR_PWD" > /etc/apt/auth.conf.d/freexian.conf
18+
RUN --mount=type=secret,id=mirror-auth,required cp /run/secrets/mirror-auth /etc/apt/auth.conf.d/freexian.conf
2319

24-
RUN apt-get update -y && \
20+
RUN --mount=type=secret,id=mirror-url,required apt-get update -y && \
2521
apt-get install -y software-properties-common language-pack-en-base && \
26-
apt-add-repository "https://$DEB_MIRROR_URL/php.freexian.com/ bookworm main" && \
22+
apt-add-repository "https://$(cat /run/secrets/mirror-url)/php.freexian.com/ bookworm main" && \
2723
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/apache2
2824

2925
RUN apt-get update -y && \

0 commit comments

Comments
 (0)