Skip to content

Commit

Permalink
Small fixes (#32)
Browse files Browse the repository at this point in the history
* fix docker build warning

prior to this, building the image was causing this warning:

```
 1 warning found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 2)
```

* dockerfiles: cache go mod dependencies in their own layer

this change causes docker to create an additional intermediate layer containing
just the go.mod file and the downloaded dependencies cited therefrom. this
prevents having to re-download the go.mod dependencies on EVERY image rebuild.
more specifically, as long as you don't change the go.mod file, docker will use
the cached layer.

* README: dev dependencies: add gci

it's used in the Makefile but, prior to this, the README didn't instruct you to
install it.
  • Loading branch information
feuGeneA authored Sep 20, 2024
1 parent d3d41f9 commit c01a101
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ go install mvdan.cc/[email protected]
go install honnef.co/go/tools/cmd/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install go.uber.org/nilaway/cmd/[email protected]
go install github.com/daixiang0/[email protected]
```

**Lint, test, format**
Expand Down
5 changes: 4 additions & 1 deletion cli.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# syntax=docker/dockerfile:1
FROM golang:1.21 as builder
FROM golang:1.21 AS builder
ARG VERSION
WORKDIR /build
ADD go.mod /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux \
go mod download
ADD . /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux \
go build \
Expand Down
5 changes: 4 additions & 1 deletion httpserver.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# syntax=docker/dockerfile:1
FROM golang:1.21 as builder
FROM golang:1.21 AS builder
ARG VERSION
WORKDIR /build
ADD go.mod /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux \
go mod download
ADD . /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux \
go build \
Expand Down

0 comments on commit c01a101

Please sign in to comment.