Add dockerfile

This commit is contained in:
mudler
2024-04-11 20:00:38 +02:00
parent 3170ee0ba2
commit 6528da804f
2 changed files with 33 additions and 1 deletions

28
Dockerfile.webui Normal file
View File

@@ -0,0 +1,28 @@
# Define argument for linker flags
ARG LDFLAGS=-s -w
# Use a temporary build image based on Golang 1.20-alpine
FROM golang:1.22-alpine as builder
# Set environment variables: linker flags and disable CGO
ENV LDFLAGS=$LDFLAGS CGO_ENABLED=0
# Install git and build the edgevpn binary with the provided linker flags
# --no-cache flag ensures the package cache isn't stored in the layer, reducing image size
RUN apk add --no-cache git
# Add the current directory contents to the work directory in the container
COPY . /work
# Set the current work directory inside the container
WORKDIR /work
RUN go build -ldflags="$LDFLAGS" -o webui ./example/webui
FROM scratch
# Copy the webui binary from the builder stage to the final image
COPY --from=builder /work/webui /webui
# Define the command that will be run when the container is started
ENTRYPOINT ["/webui"]

View File

@@ -1,7 +1,11 @@
GOCMD=go
IMAGE_NAME=webui
tests:
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --fail-fast -v -r ./...
webui:
cd example/webui && $(GOCMD) run ./
webui-image:
docker build -t $(IMAGE_NAME) -f Dockerfile.webui .