Skip to content

Commit

Permalink
Separate dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Jan 19, 2021
1 parent a23a77b commit 3c8b92a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
**/testing
**/dist
**/node_modules
Dockerfile
Dockerfile*
bindata_gzip.go
25 changes: 1 addition & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
FROM node:10.23.1-slim AS npm-builder
WORKDIR /app
ADD cmd/ui/front/package.json .
ADD cmd/ui/front/package-lock.json .
RUN npm install
ADD cmd/ui/front/ .
RUN npm run build

FROM golang:1.15.6-alpine3.12 AS go-builder
WORKDIR /src/
RUN apk --no-cache add upx git
Expand All @@ -15,27 +7,12 @@ ENV GO111MODULE on
COPY go.mod .
RUN go mod download

COPY pkg/client/go.mod pkg/client/
RUN (cd pkg/client && go mod download)

COPY cmd/client/go.mod cmd/client/
RUN (cd cmd/client && go mod download)

COPY cmd/ui/go.mod cmd/ui/
RUN (cd cmd/ui && go mod download)

COPY . .

WORKDIR /src/cmd/ui
COPY --from=npm-builder /dist dist
RUN bindata ./dist/...
RUN ls -la

RUN CGO_ENABLED=0 GOOS=linux GOPROXY=https://proxy.golang.org go build -ldflags "-s -w" -o /app/app .
RUN cd cmd/server && CGO_ENABLED=0 GOOS=linux GOPROXY=https://proxy.golang.org go build -ldflags "-s -w" -o /app/app .
RUN upx /app/app

FROM scratch
EXPOSE 8080
COPY --from=go-builder /app/app /

ENTRYPOINT [ "/app" ]
41 changes: 41 additions & 0 deletions Dockerfile.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM node:10.23.1-slim AS npm-builder
WORKDIR /app
ADD cmd/ui/front/package.json .
ADD cmd/ui/front/package-lock.json .
RUN npm install
ADD cmd/ui/front/ .
RUN npm run build

FROM golang:1.15.6-alpine3.12 AS go-builder
WORKDIR /src/
RUN apk --no-cache add upx git
RUN go get -u github.com/kataras/bindata/cmd/bindata
ENV GO111MODULE on

COPY go.mod .
RUN go mod download

COPY pkg/client/go.mod pkg/client/
RUN (cd pkg/client && go mod download)

COPY cmd/client/go.mod cmd/client/
RUN (cd cmd/client && go mod download)

COPY cmd/ui/go.mod cmd/ui/
RUN (cd cmd/ui && go mod download)

COPY . .

WORKDIR /src/cmd/ui
COPY --from=npm-builder /dist dist
RUN bindata ./dist/...
RUN ls -la

RUN CGO_ENABLED=0 GOOS=linux GOPROXY=https://proxy.golang.org go build -ldflags "-s -w" -o /app/app .
RUN upx /app/app

FROM scratch
EXPOSE 8080
COPY --from=go-builder /app/app /

ENTRYPOINT [ "/app" ]

0 comments on commit 3c8b92a

Please sign in to comment.