Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support user build-arg #428

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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