Skip to content

Commit

Permalink
faster docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantoro committed Aug 19, 2022
1 parent 4eb2a62 commit aadc25e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
build
.vscode
.github
.dev-tools
tmp
.gitignore
.golangci.yml
cmd
go.mod
go.sum
6 changes: 5 additions & 1 deletion dev-tools/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ tasks:
# Docker
####
docker-build:
deps: [build]
cmds:
- cd .. && docker build -t go-sample-app:latest -f dev-tools/docker/Dockerfile .

docker-inspect:
cmds:
- dive go-sample-app:latest

docker-run:
cmds:
- docker run -it go-sample-app:latest

####
# Asciinema
Expand Down Expand Up @@ -58,7 +62,7 @@ tasks:
####
build:
cmds:
- go build -v -tags=go_json -o ../build/hello ../cmd/hello.go
- GOOS=linux GOARCH=amd64 go build -v -tags=go_json -o ../build/hello ../cmd/hello.go

run:
cmds:
Expand Down
12 changes: 1 addition & 11 deletions dev-tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
FROM golang:1.19-bullseye as build

WORKDIR /go/src/app
ADD . /go/src/app/

RUN go get -d -v ./...
RUN go build -o /go/bin/app cmd/hello.go

###

FROM gcr.io/distroless/base-debian11

COPY --from=build /go/bin/app /
COPY build/hello /app
CMD ["/app"]

0 comments on commit aadc25e

Please sign in to comment.