forked from Dicklesworthstone/ntm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (43 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
57 lines (43 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
52
53
54
55
56
57
# syntax=docker/dockerfile:1
# Build stage
FROM golang:1.25-alpine AS builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source
COPY . .
# Build with optimizations
ARG VERSION=dev
ARG COMMIT=unknown
ARG DATE=unknown
RUN CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-s -w \
-X github.com/Dicklesworthstone/ntm/internal/cli.Version=${VERSION} \
-X github.com/Dicklesworthstone/ntm/internal/cli.Commit=${COMMIT} \
-X github.com/Dicklesworthstone/ntm/internal/cli.Date=${DATE} \
-X github.com/Dicklesworthstone/ntm/internal/cli.BuiltBy=docker" \
-o /ntm ./cmd/ntm
# Runtime stage
FROM alpine:3.19
# Install runtime dependencies
RUN apk add --no-cache \
tmux \
ca-certificates \
tzdata \
bash \
zsh
# Create non-root user
RUN adduser -D -g '' ntm
USER ntm
WORKDIR /home/ntm
# Copy binary
COPY --from=builder /ntm /usr/local/bin/ntm
# Default shell init
RUN echo 'eval "$(ntm shell bash)"' >> ~/.bashrc && \
echo 'eval "$(ntm shell zsh)"' >> ~/.zshrc
ENTRYPOINT ["ntm"]
CMD ["--help"]