chore: pass git creds into docker build
Some checks failed
itom-platform auto build image / build (push) Failing after 3m55s

This commit is contained in:
kim.dev.6789
2026-01-15 17:08:56 +08:00
parent 0ee1b61219
commit 1103da3414
2 changed files with 27 additions and 1 deletions

View File

@@ -5,6 +5,15 @@ FROM golang:1.22-alpine AS builder
ENV SERVER_DIR=/openim-server
ENV GOWORK=off
# Credentials for private module access (optional)
ARG GIT_USER
ARG GIT_TOKEN
ARG REGISTRY_USER
ARG REGISTRY_PASSWORD
ENV GOPRIVATE=git.imall.cloud
ENV GONOSUMDB=git.imall.cloud
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
@@ -17,6 +26,13 @@ RUN apk add --no-cache git
# Copy all files from the current directory into the container
COPY . .
RUN set -eu; \
user="${GIT_USER:-$REGISTRY_USER}"; \
token="${GIT_TOKEN:-$REGISTRY_PASSWORD}"; \
if [ -n "$user" ] && [ -n "$token" ]; then \
git config --global url."https://${user}:${token}@git.imall.cloud/".insteadOf "https://git.imall.cloud/"; \
fi
RUN go mod download
# Install Mage to use for building the application