-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
66 lines (51 loc) · 1.54 KB
/
Dockerfile.dev
File metadata and controls
66 lines (51 loc) · 1.54 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
58
59
60
61
62
63
64
65
66
# Development Dockerfile with shell access and debugging tools
FROM golang:1.24.4-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download && go mod verify
# Copy source code (only what's needed for build)
COPY main.go ./
COPY cmd/ ./cmd/
COPY internal/ ./internal/
# Accept version and target architecture as build arguments
ARG VERSION=dev
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build \
-ldflags="-w -s -extldflags '-static' -X 'github.com/developerkunal/OpenMorph/cmd.version=${VERSION}'" \
-a -installsuffix cgo \
-o openmorph \
./main.go
# Development stage with shell and debugging tools
FROM alpine:3.20
# Install Node.js and useful tools for development and debugging
RUN apk add --no-cache \
bash \
curl \
jq \
yq \
git \
vim \
tree \
ca-certificates \
nodejs \
npm
# Install swagger-cli globally
RUN npm install -g @apidevtools/swagger-cli
# Create non-root user for security
RUN addgroup -g 1001 -S openmorph && \
adduser -u 1001 -S openmorph -G openmorph
# Copy the binary
COPY --from=builder /build/openmorph /usr/local/bin/openmorph
# Make it executable
RUN chmod +x /usr/local/bin/openmorph
# Switch to non-root user
USER openmorph
# Create workspace directory
WORKDIR /workspace
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/usr/local/bin/openmorph", "--version"] || exit 1
# Set up shell
CMD ["/bin/bash"]