Skip to content

Commit

Permalink
Improve Docker build.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed May 6, 2019
1 parent c798ffb commit fecd718
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.git
vendor/
cmd/k8s-copier/debug
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
.DS_Store
.idea
/acmesolver
/controller
/ingress-shim
/hack/build/dockerfiles/cert-manager-*_*_*
.vscode
.venv
bazel-*
/.settings/
/.project
vendor/
debug
k8s-copier

15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/cmd/k8s-copier/main.go"
},
]
}
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# build stage
FROM golang:alpine AS build-env
RUN apk add git gcc
ADD . /src
RUN cd /src && go build -o k8s-copier

WORKDIR $GOPATH/src/github.com/michaelfig/k8s-copier
COPY . .

# Download all the dependencies
RUN GO111MODULE=on go mod vendor

# Install the binaries
RUN go install -v ./cmd/k8s-copier

WORKDIR /app
RUN cp $GOPATH/bin/k8s-copier /app/

# final stage
FROM alpine

LABEL maintainer="Michael FIG <[email protected]>"

WORKDIR /app
COPY --from=build-env /src/k8s-copier /app/
COPY --from=build-env /app/k8s-copier /app/
CMD ./k8s-copier
1 change: 1 addition & 0 deletions cmd/k8s-copier/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debug

0 comments on commit fecd718

Please sign in to comment.