Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit 0510134

Browse files
committed
Retrieve the UID for the mysql user and pass in when building the
mysql-agent image, rather than hardcoding a UID in the Dockerfile. Signed-off-by: Kashif Saadat <kashifsaadat@gmail.com>
1 parent 5db756b commit 0510134

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ build-docker:
7878
-t $(REGISTRY)/$(TENANT)/mysql-operator:$(VERSION) \
7979
-f docker/mysql-operator/Dockerfile .
8080

81+
# Retrieve the UID for the mysql user, passed in when building the mysql-agent image
82+
$(eval MYSQL_AGENT_IMAGE := $(shell sed -n 's/^FROM \(.*\)/\1/p' docker/mysql-agent/Dockerfile))
83+
$(eval MYSQL_UID=$(shell docker run --rm --entrypoint id ${MYSQL_AGENT_IMAGE} -u mysql))
84+
8185
@docker build \
8286
--build-arg=http_proxy \
8387
--build-arg=https_proxy \
88+
--build-arg=MYSQL_USER=${MYSQL_UID} \
8489
-t $(REGISTRY)/$(TENANT)/mysql-agent:$(VERSION) \
8590
-f docker/mysql-agent/Dockerfile .
8691

docker/mysql-agent/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM mysql/mysql-server:8.0.12
22

33
COPY bin/linux_amd64/mysql-agent /
44

5-
# Reference the UID for the 'mysql' user
6-
USER 27
5+
# Set default value for 'MYSQL_USER', which is overridden with the UID at build time
6+
ARG MYSQL_USER=mysql
7+
USER ${MYSQL_USER}
78

89
ENTRYPOINT ["/mysql-agent"]

0 commit comments

Comments
 (0)