Refactor build steps

This commit is contained in:
Anthony Mineo 2020-03-07 11:01:21 -05:00
parent d17efed959
commit 964b024b02
7 changed files with 57 additions and 21 deletions

View file

@ -1,19 +1,42 @@
FROM golang:1.13.6
# [ Stage 1] Builder
FROM golang:alpine AS builder
# Set necessary environmet variables needed for our image
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
WORKDIR /app
COPY ./app/t2-stats /app
# Copy and download dependency using go mod
RUN go mod download
# # Go Packages
# RUN go get -u -v \
# # GUID Generator
# github.com/rs/xid \
# # PostgreSQL Driver
# github.com/jackc/pgx \
# github.com/jmoiron/sqlx \
# # Better Error Handling
# github.com/pkg/errors
RUN go build -o main .
# [ Stage 2]
FROM golang:alpine
LABEL maintainer="Anthony Mineo <anthonymineo@gmail.com>"
WORKDIR /app
# Go Packages
RUN go get -u -v \
# GUID Generator
github.com/rs/xid \
# PostgreSQL Driver
github.com/jackc/pgx \
github.com/jmoiron/sqlx \
# Better Error Handling
github.com/pkg/errors
COPY --from=builder /app/main /app/main
COPY ./app/t2-stats/start.sh /app/start.sh
COPY ./app/t2-stats /app
ENTRYPOINT go run main.go
ENTRYPOINT ./start.sh