forked from rubensa/docker-ubuntu-tini-user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-custom.sh
executable file
·35 lines (29 loc) · 1.07 KB
/
build-custom.sh
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
#!/usr/bin/env bash
DOCKER_REPOSITORY_NAME="nextail"
DOCKER_IMAGE_NAME="ubuntu-tini-user"
DOCKER_IMAGE_TAG="latest"
# Get current user UID
USER_ID=$(id -u)
# Get current user main GID
GROUP_ID=$(id -g)
# Get current user name
USER_NAME=$(id -un)
# Get current user main group name
GROUP_NAME=$(id -gn)
prepare_docker_user_and_group() {
# On build, if you specify USER_NAME, USER_ID, GROUP_NAME or GROUP_ID those are used to define the
# internal user and group created instead of default ones (user:1000 and group:1000)
BUILD_ARGS+=" --build-arg USER_ID=$USER_ID"
BUILD_ARGS+=" --build-arg GROUP_ID=$GROUP_ID"
BUILD_ARGS+=" --build-arg USER_NAME=$USER_NAME"
BUILD_ARGS+=" --build-arg GROUP_NAME=$GROUP_NAME"
}
prepare_docker_user_and_group
docker buildx build --platform=linux/amd64,linux/arm64 --no-cache \
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \
--label "maintainer=Ruben Suarez <[email protected]>" \
${BUILD_ARGS} \
.
docker buildx build --load \
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \
.