mirror of
https://github.com/vmorganp/Lazytainer.git
synced 2025-12-21 13:23:02 +01:00
fix: slim container image... (#6)
* fix: slim container image... - Add ignore all exept go files in .dockerignore - Remove unnecessary spaces * fix: alpine based image, install g++ in build ... * For trimpath and ldflags s w * fix: scratch base, static bin, utilize buildkit... - Use scratch base image - Use golang buster as build image - Static bunary - Utilize buildkit with gomod and build caching Authored-by: pratikbin <pratikbin+010101@no-reply-github.com>
This commit is contained in:
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
||||
# Ignore everything
|
||||
*
|
||||
|
||||
# But these files...
|
||||
!**/go.**
|
||||
!**.go
|
||||
23
Dockerfile
23
Dockerfile
@@ -1,13 +1,12 @@
|
||||
FROM golang:alpine3.15
|
||||
# syntax = docker/dockerfile:latest
|
||||
FROM golang as build
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
go mod tidy; \
|
||||
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o lazytainer ./...
|
||||
|
||||
WORKDIR /root/
|
||||
COPY ./go.mod ./go.sum ./
|
||||
RUN go mod download
|
||||
COPY ./lazytainer.go .
|
||||
RUN go build lazytainer.go
|
||||
|
||||
FROM alpine:latest
|
||||
WORKDIR /root/
|
||||
COPY --from=0 /root/lazytainer ./
|
||||
|
||||
CMD ["./lazytainer"]
|
||||
FROM scratch
|
||||
COPY --from=build /app/lazytainer /usr/local/bin/lazytainer
|
||||
ENTRYPOINT ["/usr/local/bin/lazytainer"]
|
||||
|
||||
Reference in New Issue
Block a user