diff --git a/Dockerfile.webui b/Dockerfile.webui new file mode 100644 index 0000000..03a034b --- /dev/null +++ b/Dockerfile.webui @@ -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"] \ No newline at end of file diff --git a/Makefile b/Makefile index a30ebba..f0f509f 100644 --- a/Makefile +++ b/Makefile @@ -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 ./ \ No newline at end of file + cd example/webui && $(GOCMD) run ./ + +webui-image: + docker build -t $(IMAGE_NAME) -f Dockerfile.webui . \ No newline at end of file