Created
October 14, 2021 22:55
-
-
Save kcollasarundell/3f0937b5e1643e48af06d651c9754e94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile References: https://docs.docker.com/engine/reference/builder/ | |
############################################ MULTI STAGE BUILD PART 1 ############################################## | |
# Start from golang v1.17 base image | |
FROM golang:1.17 as builder | |
# Creating/Cd work directory | |
WORKDIR /app | |
# Copying sources | |
COPY . . | |
# Run go build | |
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 /usr/local/go/bin/go build -ldflags="-s -w" -o /app/pack-and-go-api . | |
# Add wait-for-it tool | |
ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh /app/wait-for-it | |
RUN chmod +x /app/wait-for-it | |
############################################ MULTI STAGE BUILD PART 2 ############################################## | |
# Using bash | |
FROM bash | |
# Copying executable | |
COPY --from=builder /app/pack-and-go-api . | |
COPY --from=builder /app/.env . | |
COPY --from=builder /app/wait-for-it . | |
CMD /app/wait-for-it database:5432 -- /app/pack-and-go-api |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment