customer/Dockerfile

52 lines
1.0 KiB
Docker
Raw Normal View History

2023-06-22 09:36:43 +00:00
# BUILD
FROM golang:1.20.3-alpine AS build
2023-09-14 10:07:28 +00:00
# Update packages and clear cache
2023-11-01 07:56:05 +00:00
RUN apk add --no-cache curl
2023-09-14 10:07:28 +00:00
# Set work directory
WORKDIR /app
# Create binary directory
2023-06-22 09:36:43 +00:00
RUN mkdir /app/bin -p
2023-09-14 10:07:28 +00:00
# Create golang migrate util directory
2023-06-22 09:36:43 +00:00
RUN mkdir /bin/golang-migrate -p
2023-09-14 10:07:28 +00:00
# Add migrate tool
ADD ./tools/migrate /bin/golang-migrate/
# Add main files to app
ADD . .
2023-06-22 09:36:43 +00:00
# Build app
RUN GOOS=linux go build -o bin ./...
# TEST
2023-09-14 10:07:28 +00:00
FROM alpine:3.18.3 AS test
2023-06-22 09:36:43 +00:00
# Install packages
2023-11-01 07:56:05 +00:00
RUN apk --no-cache add ca-certificates
2023-06-22 09:36:43 +00:00
# Create home directory
WORKDIR /app
# Copy build file
COPY --from=build /app/bin/app ./app
# Copy migration dir
COPY --from=build /app/migrations/test ./migrations
# Install migrate tool
COPY --from=build /bin/golang-migrate /usr/local/bin
2023-09-14 10:07:28 +00:00
# CMD
CMD [ "./app" ]
2023-06-22 09:36:43 +00:00
# PRODUCTION
2023-09-14 10:07:28 +00:00
FROM alpine:3.18.3 AS production
2023-06-22 09:36:43 +00:00
# Install packages
2023-11-02 12:28:24 +00:00
RUN apk --no-cache add ca-certificates
2023-06-22 09:36:43 +00:00
# Create home directory
WORKDIR /app
# Copy build file
COPY --from=build /app/bin/app ./app
# Install migrate tool
COPY --from=build /bin/golang-migrate /usr/local/bin
# CMD
CMD ["./app"]