feat: Docker file
This commit is contained in:
+18
-6
@@ -16,29 +16,41 @@ RUN go mod download
|
||||
|
||||
# Copy the code into the container
|
||||
COPY . .
|
||||
# Some different way for vendoring
|
||||
#RUN go mod tidy && go mod vendor
|
||||
|
||||
# Build the application
|
||||
RUN go build -o build/app .
|
||||
RUN go build -ldflags "-s -w" -o /build/app .
|
||||
|
||||
FROM scratch
|
||||
|
||||
# or alpine, if you need install utilities
|
||||
#
|
||||
#FROM alpine:latest
|
||||
#
|
||||
## Add entrypoint dependency
|
||||
#RUN apk add --no-cache bash mysql-client mariadb-connector-c
|
||||
|
||||
# Move to /app directory as the place for resulting binary folder
|
||||
WORKDIR /
|
||||
|
||||
# Copy binary from build to main folder
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /source/build/app app
|
||||
COPY --from=builder /build/app app
|
||||
|
||||
# Copy some application assets
|
||||
#COPY --from=builder /source/docker/environment.sh ./docker/environment.sh
|
||||
#COPY --from=builder /source/docker/logging.sh ./docker/logging.sh
|
||||
#COPY --from=builder /source/entrypoint.sh .
|
||||
#COPY --from=builder /source/migrations ./migrations
|
||||
#COPY ./database/data.json /database/data.json
|
||||
|
||||
# Export necessary port
|
||||
#EXPOSE 3000
|
||||
|
||||
ENTRYPOINT ["/app"]
|
||||
# entry and start entrypoint with some actions and checks before CMD
|
||||
#ENTRYPOINT ["bash", "/entrypoint.sh" ]
|
||||
|
||||
# Command to run when starting the container
|
||||
#CMD ["/app"]
|
||||
CMD ["/app"]
|
||||
|
||||
# if have not application daemon
|
||||
#CMD tail -f /dev/null
|
||||
Reference in New Issue
Block a user