Skip to content

Commit 34c19c4

Browse files
committed
feat: update dockerfile
1 parent a4dc699 commit 34c19c4

2 files changed

Lines changed: 42 additions & 63 deletions

File tree

build/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM golang:1.24.3 AS build
2+
WORKDIR /app/src
3+
4+
ENV GOCACHE=/root/.cache/go-build
5+
ENV GOMODCACHE=/root/.cache/go-build
6+
ENV GO111MODULE=on
7+
ENV CGO_ENABLED=0
8+
ENV GOOS=linux
9+
10+
# Leverage build cache by copying go.mod and go.sum first
11+
COPY go.mod go.sum ./
12+
RUN --mount=type=cache,target=/root/.cache/go-build go mod download
13+
RUN go mod verify
14+
15+
# Copy the rest of the source code
16+
COPY . .
17+
18+
RUN --mount=type=cache,target="/root/.cache/go-build" go build -o ./chargeflow ./cmd
19+
20+
FROM debian:buster-slim as app
21+
22+
RUN apt-get update
23+
24+
SHELL ["/bin/sh", "-l", "-c"]
25+
26+
ARG user=app
27+
ARG group=docker
28+
RUN addgroup $group
29+
RUN adduser \
30+
--disabled-password \
31+
--gecos "" \
32+
--ingroup $group \
33+
$user
34+
USER $user
35+
36+
WORKDIR /usr/local/bin
37+
38+
# Copy the binary and set execute permissions
39+
COPY --chown=$user:$group --from=build /app/chargeflow /usr/local/bin/chargeflow
40+
RUN chmod +x /usr/local/bin/chargeflow
41+
42+
CMD ["/usr/local/bin/chargeflow"]

build/service/Dockerfile

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)