-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
38 lines (27 loc) · 1006 Bytes
/
Dockerfile
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
# Base image for Go
FROM golang:1.23 as builder
# Set the working directory inside the container
WORKDIR /app
# Copy go modules and install dependencies
COPY go.mod go.sum ./
COPY vendor/ ./vendor/
COPY Makefile ./Makefile
RUN make vendor
# Copy the entire project into the container
COPY . .
# Build the CLI using the Makefile
RUN make build
# Final stage: minimal runtime image
FROM alpine:latest
# Set up a non-root user for security
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Set the working directory inside the runtime container
WORKDIR /app
# Copy the built CLI binary from the builder stage
COPY --from=builder /app/bin/linux-amd64/no-barrel-file /usr/local/bin/no-barrel-file
# Change ownership and grant execution permissions
RUN chown appuser:appgroup /usr/local/bin/no-barrel-file && chmod +x /usr/local/bin/no-barrel-file
# Switch to the non-root user
USER appuser
# Set the default command to display the help message
ENTRYPOINT ["/usr/local/bin/no-barrel-file"]