-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.console
More file actions
51 lines (37 loc) · 1.19 KB
/
Dockerfile.console
File metadata and controls
51 lines (37 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Multi-stage Dockerfile for Console interactive client
FROM golang:1.23 AS builder
# Setup the working directory
WORKDIR /app
# Install dependencies
COPY go.mod go.sum ./
RUN go mod download
# Add source code
COPY cmd/ cmd/
COPY internal/ internal/
# Copy test certificates
COPY internal/certs/files/test internal/certs/files
COPY protogen/ protogen/
# Build the console binary
RUN CGO_ENABLED=0 GOOS=linux GOFLAGS="-ldflags=-s -ldflags=-w" go build -o console ./cmd/console/
# Runtime stage
FROM alpine:latest
# Create user and group
RUN addgroup -g 1001 dop && \
adduser -D -u 1001 -G dop dop
# Set working directory
RUN mkdir -p /app
WORKDIR /app
ARG MINEXUS_ENV
COPY .env.${MINEXUS_ENV} ./.env.${MINEXUS_ENV}
# Copy the binary from builder
COPY --from=builder /app/console /app/console
# Create entrypoint script (use printf for proper newlines)
RUN printf '#!/bin/sh\nexec /app/console\n' > /app/docker-entrypoint.sh && \
chmod +x /app/docker-entrypoint.sh
# Set ownership for Kubernetes compatibility
RUN chgrp -R 0 /app && chmod -R g=u /app
# Switch to non-root user
USER 1001
# Set up terminal environment for interactive use
ENV TERM=xterm-256color
ENTRYPOINT ["/app/docker-entrypoint.sh"]