Skip to content

Commit

Permalink
Switch from golang base image to alpine
Browse files Browse the repository at this point in the history
No need to have the go development tools in our run-time image.

Signed-off-by: Toby Cabot <toby@acnodal.io>
  • Loading branch information
caboteria committed Sep 12, 2023
1 parent 1af379b commit 2c10859
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
FROM golang:1.17-alpine as builder
FROM golang:1.17.13-alpine as builder

ENV GOOS=linux

WORKDIR /opt/acnodal/src
WORKDIR /opt/epic-gateway/src
COPY . ./

# build the web service (static)
# build the executable (static)
RUN go build -tags 'osusergo netgo' -o ../bin/web-service main.go


# start fresh
FROM golang:1.17-alpine
ENV bin=/opt/acnodal/bin/web-service
FROM alpine:3.16.7

# copy executables from the builder image
# copy executable from the builder image
ENV bin=/opt/epic-gateway/bin/web-service
COPY --from=builder ${bin} ${bin}

EXPOSE 8080

# The softlink is because Dockerfile variable interpolation happens at
# run-time so if you have variables in the CMD string they won't get
# resolved to their values. This lets us have a hard-coded CMD string
# that links to the image-specific command.
RUN ln -s ${bin} /opt/acnodal/bin/cmd
CMD ["/opt/acnodal/bin/cmd"]
CMD ["/opt/epic-gateway/bin/web-service"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ run: ## Run the service using "go run" (KUBECONFIG needs to be set)
docker-build: ## Build the Docker image
docker build --tag=${TAG} ${DOCKER_BUILD_OPTIONS} .

docker-push: image ## Push the image to the registry
docker-push: docker-build ## Push the image to the registry
docker push ${TAG}

.PHONY: manifest
Expand Down

0 comments on commit 2c10859

Please sign in to comment.