Updating dependencies + fix dockerfile for quicker build + Introducing top Makefile script as unique entry point for building, deployment and high level tasks
This commit is contained in:
52
Dockerfile
52
Dockerfile
@@ -1,32 +1,48 @@
|
||||
FROM golang:alpine as builder
|
||||
FROM golang:alpine AS deps
|
||||
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN sed -i '/replace/d' go.mod
|
||||
RUN cat go.mod
|
||||
RUN go mod download
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
ARG HOSTNAME=http://localhost
|
||||
ARG NAME=local
|
||||
|
||||
WORKDIR /app
|
||||
RUN apk add git
|
||||
|
||||
RUN go install github.com/beego/bee/v2@latest
|
||||
|
||||
WORKDIR /oc-auth
|
||||
|
||||
COPY --from=deps /go/pkg /go/pkg
|
||||
COPY --from=deps /app/go.mod /app/go.sum ./
|
||||
|
||||
RUN export CGO_ENABLED=0 && \
|
||||
export GOOS=linux && \
|
||||
export GOARCH=amd64 && \
|
||||
export BUILD_FLAGS="-ldflags='-w -s'"
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN apk add git
|
||||
RUN sed -i '/replace/d' go.mod
|
||||
RUN bee pack
|
||||
RUN mkdir -p /app/extracted && tar -zxvf oc-auth.tar.gz -C /app/extracted
|
||||
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' /app/extracted/swagger/index.html
|
||||
|
||||
RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
||||
RUN timeout 15 bee run -gendoc=true -downdoc=true -runmode=dev || :
|
||||
|
||||
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" .
|
||||
|
||||
RUN ls /app
|
||||
|
||||
FROM scratch
|
||||
FROM golang:alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/oc-auth /usr/bin/
|
||||
COPY --from=builder /app/swagger /app/swagger
|
||||
|
||||
COPY docker_auth.json /etc/oc/auth.json
|
||||
COPY --from=builder /app/extracted/oc-auth /usr/bin
|
||||
COPY --from=builder /app/extracted/swagger /app/swagger
|
||||
COPY --from=builder /app/extracted/pem /app/pem
|
||||
COPY --from=builder /app/extracted/docker_auth.json /etc/oc/auth.json
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
|
||||
Reference in New Issue
Block a user