chore: write dockerfiles for agent and backend

This commit is contained in:
d3m0k1d
2026-04-03 19:43:13 +03:00
parent b75d95f9a7
commit 9992e254d5
2 changed files with 50 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
FROM golang:1.26.1 as builder
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
ENV CGO_ENABLED=0
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -ldflags "-s -w" -o agent ./cmd/main.go
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
systemd \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/agent .
CMD ["./agent"]
+24
View File
@@ -0,0 +1,24 @@
FROM golang:1.26.1 as builder
WORKDIR /app
COPY . .
ENV CGO_ENABLED=0
ENV GIN_MODE=release
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download && \
go build -ldflags "-s -w" -o backend ./cmd/main.go
FROM alpine:3.23.0
RUN apk add --no-cache curl openssl bash
COPY --from=builder /app/backend .
COPY --from=builder /app/scripts /etc/mnemosyne/scripts
RUN chmod +x /etc/mnemosyne/scripts/generate-certs.sh
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "curl --fail http://localhost:8080/health" ]
CMD ["./backend"]