Skip to content

Commit

Permalink
support user build-arg (#428)
Browse files Browse the repository at this point in the history
* support user build-arg

* simplify

* set default user
  • Loading branch information
MegaByte875 authored Jan 26, 2024
1 parent f33b020 commit a9430a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM alpine:3.18.2

ARG TARGETDIR
ARG USERNAME

RUN addgroup -S -g 65532 ng-user && \
RUN if [ "$USERNAME" = "ng-user" ]; then \
addgroup -S -g 65532 ng-user && \
adduser -S -D -H -u 65532 \
-s /sbin/nologin -G ng-user -g ng-user ng-user
-s /sbin/nologin -G ng-user -g ng-user ng-user; \
fi

ADD bin/${TARGETDIR}/controller-manager /usr/local/bin/controller-manager
ADD bin/${BUILDPLATFORM}/autoscaler /usr/local/bin/autoscaler
ADD bin/${TARGETDIR}/autoscaler /usr/local/bin/autoscaler
ADD bin/${TARGETDIR}/scheduler /usr/local/bin/scheduler
USER 65532:65532

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
11 changes: 8 additions & 3 deletions Dockerfile.multiarch
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM alpine:3.18.2

ARG TARGETPLATFORM
ARG USERNAME

RUN addgroup -S -g 65532 ng-user && \
RUN if [ "$USERNAME" = "ng-user" ]; then \
addgroup -S -g 65532 ng-user && \
adduser -S -D -H -u 65532 \
-s /sbin/nologin -G ng-user -g ng-user ng-user
-s /sbin/nologin -G ng-user -g ng-user ng-user; \
fi

ADD bin/${TARGETPLATFORM}/controller-manager /usr/local/bin/controller-manager
ADD bin/${TARGETPLATFORM}/autoscaler /usr/local/bin/autoscaler
ADD bin/${TARGETPLATFORM}/scheduler /usr/local/bin/scheduler
USER 65532:65532

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LDFLAGS = $(if $(DEBUGGER),,-s -w) $(shell ./hack/version.sh)

DOCKER_REGISTRY ?= docker.io
DOCKER_REPO ?= ${DOCKER_REGISTRY}/vesoft
IMAGE_TAG ?= v1.7.0
USERNAME ?= ng-user
IMAGE_TAG ?= v1.7.5

CHARTS_VERSION ?= 1.7.0

Expand Down Expand Up @@ -104,6 +105,7 @@ docker-multiarch: ensure-buildx ## Build and push the nebula-operator multiarchi
--progress plain \
--platform $(BUILDX_PLATFORMS) \
--file Dockerfile.multiarch \
--build-arg USERNAME=${USERNAME} \
-t "${DOCKER_REPO}/nebula-operator:${IMAGE_TAG}" .

alpine-tools: ## Build and push the alpine-tools docker images and manifest.
Expand Down

0 comments on commit a9430a4

Please sign in to comment.