55 lines
1.5 KiB
Docker
55 lines
1.5 KiB
Docker
# Base Image for kami-gateway applications
|
|
# Contains Go 1.25 build environment and Alpine runtime
|
|
|
|
FROM golang:1.25-alpine
|
|
|
|
# Set environment variables
|
|
ENV TZ=Asia/Shanghai \
|
|
GO111MODULE=on \
|
|
# GOPROXY=https://goproxy.io,direct \
|
|
CGO_ENABLED=0 \
|
|
GOOS=linux \
|
|
GOARCH=amd64
|
|
|
|
# Install all dependencies
|
|
RUN apk update && \
|
|
apk upgrade && \
|
|
apk add --no-cache \
|
|
tzdata \
|
|
curl \
|
|
ca-certificates \
|
|
git && \
|
|
# Set timezone
|
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
echo "Asia/Shanghai" > /etc/timezone && \
|
|
# Clean up
|
|
rm -rf /var/cache/apk/*
|
|
|
|
# Download custom certificates (skip problematic Alpine package, use curl instead)
|
|
RUN curl -fsSL -o /usr/local/share/ca-certificates/aaa-certificate-services.crt https://www.tbs-x509.com/Comodo_AAA_Certificate_Services.crt && \
|
|
update-ca-certificates
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S appuser && \
|
|
adduser -u 1001 -S appuser -G appuser -h /app -s /bin/sh
|
|
|
|
# Create application directory
|
|
RUN mkdir -p /app && \
|
|
chown -R appuser:appuser /app
|
|
|
|
# Switch to appuser
|
|
USER appuser
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy Go modules files for dependency management
|
|
COPY --chown=appuser:appuser go.mod go.sum* ./
|
|
|
|
# Pre-download Go dependencies for faster builds
|
|
RUN go mod download && go mod verify
|
|
|
|
# Label the image
|
|
LABEL maintainer="kami-gateway-team" \
|
|
version="1.0.0" \
|
|
description="Base image for kami-gateway applications with Go 1.25 and Alpine runtime" |