Skip to content

Commit

Permalink
added Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Oct 2, 2024
1 parent 919e7ec commit f956c6b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@ cover-html: ## Run tests with coverage and open the HTML report
go test -coverprofile=/tmp/go-sim-lb.cover.tmp ./...
go tool cover -html=/tmp/go-sim-lb.cover.tmp
unlink /tmp/go-sim-lb.cover.tmp

.PHONY: docker-images
docker-images: ## Build the Docker images
DOCKER_BUILDKIT=1 docker build \
--platform linux/amd64 \
--build-arg VERSION=${VERSION} \
--file proxy-server.dockerfile \
--tag cvm-proxy-server \
.
23 changes: 23 additions & 0 deletions proxy-server.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1
FROM golang:1.23 AS builder
ARG VERSION
WORKDIR /build
ADD go.mod /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux \
go mod download
ADD . /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux \
go build \
-trimpath \
-ldflags "-s -X main.version=${VERSION}" \
-v \
-o proxy-server \
cmd/proxy-server/main.go

FROM alpine:latest
WORKDIR /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /build/proxy-server /app/proxy-server
ENV LISTEN_ADDR=":8080"
EXPOSE 8080
CMD ["/app/proxy-server"]

0 comments on commit f956c6b

Please sign in to comment.