chore: pass git creds into docker build
Some checks failed
itom-platform auto build image / build (push) Failing after 3m55s
Some checks failed
itom-platform auto build image / build (push) Failing after 3m55s
This commit is contained in:
16
Dockerfile
16
Dockerfile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user