diff --git a/Dockerfile.workspace b/Dockerfile.workspace deleted file mode 100644 index 1b9f86c..0000000 --- a/Dockerfile.workspace +++ /dev/null @@ -1,36 +0,0 @@ -FROM golang:1.22.3-alpine3.18 - -ARG PROJECT -ARG GO_MODULE - -ENV \ - CACHE_BASE=/cache/$PROJECT \ - GO111MODULE=on \ - GOPRIVATE=$GO_MODULE \ - GOPATH=/cache/$PROJECT/Linux/x86_64/go \ - GOBIN=/cache/$PROJECT/Linux/x86_64/gobin \ - PATH=/cache/$PROJECT/Linux/x86_64/gobin:/cache/$PROJECT/Linux/x86_64/bin:${PATH} - -WORKDIR /workspace - -RUN apk add --update --no-cache \ - bash \ - build-base \ - ca-certificates \ - curl \ - git \ - openssh-client \ - unzip \ - wget && \ - rm -rf /var/cache/apk/* - -RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \ - wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0.apk && \ - apk add --no-cache glibc-2.31-r0.apk && \ - rm -rf /var/cache/apk/* - -COPY go.mod go.sum /workspace/ -RUN go mod download -COPY make /workspace/make -COPY Makefile /workspace/ -RUN make dockerdeps diff --git a/README.md b/README.md index 3289d56..9bf2fca 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,6 @@ The following are controlled by makego, and should not be edited directly: - [.gitignore](.gitignore) The autogenerated git ignore file. - [go.mod](go.mod), [go.sum](go.sum) - The Golang module files. These are autogenerated. -Additionally, makego expects the following if Docker is used: - -- [Dockerfile.workspace](Dockerfile.workspace) the Dockerfile for development of your Golang - repository. If you include [make/go/docker.mk](make/go/docker.mk), this file should be present. - Otherwise, you're free to choose your own layout, however you should generally do the following: - Have a file `make/PROJECT/all.mk` such as [make/foo/all.mk](make/foo/all.mk) that defines the @@ -164,7 +159,7 @@ We are not documenting all development commands, however some important ones of - `make all` - This is the default goal, and runs linting and testing. - `make ci` - This is the goal for CI, and downloads deps, and runs linting, testing, and code coverage. - Note that deps are downloaded automatically on a per-target basis, so the intial dep download really + Note that deps are downloaded automatically on a per-target basis, so the initial dep download really shouldn't be needed. - `make generate` - Do all generation. - `make lint` - Do all linting. @@ -172,8 +167,6 @@ We are not documenting all development commands, however some important ones of - `make test` - Go test. - `make cover` - Go code coverage. - `make install` - Install all Go binaries defined by `GO_BINS`. -- `make dockermakeworkspace` - This will run `make all` by default inside the Docker container - defined by `Docker.workspace`. You can edit the Makefile target with `DOCKERMAKETARGET`. - `make dockerbuild` - Build all Docker images defined by `DOCKER_BINS`. - `make updatemakego` - Update from makego main. @@ -207,7 +200,7 @@ These variables are settable in your Makefiles, but should be static, i.e. these project-specific settings and not intended to be set on the command line. - `FILE_IGNORES` - The relative paths to files to add to `.dockerignore` and `.gitignore`. By - default, makego will add `.env`, `.tmp`. and any Golang binaries. + default, makego will add `.env`, `.tmp`, and any Golang binaries. Note if you set this, you should do so by including the current value ie `FILE_IGNORES := $(FILE_IGNORES) .build/`. - `CACHE_BASE` - By default, makego caches to `~/.cache/$(PROJECT)`. Set this to change that. - `GO_BINS` - The relative paths to your Golang main packages, For example `cmd/foo`. @@ -232,9 +225,7 @@ These variables are meant to be set when invoking make targets on the command li against updating when not intended. - `ALL` - This results in all makego files being downloaded when running `make updatemakego` instead of just the ones that you current have included. -- `DOCKERMAKETARGET` - This changes the recursive make target for `make dockermakeworkspace` from - `all` to this value. - `GOPKGS` - This controls what packages to build for Go commands. By default, this is `./...`. If you only wanted to test `./internal/foo/...` for example, you could run `make test GOPKGS=./internal/foo/...` - `COVEROPEN` - This will result in the `cover.html` file being automatically opened after `make - cover` is run, for example `make cover COVEROPEN=1. + cover` is run, for example `make cover COVEROPEN=1`. diff --git a/make/go/docker.mk b/make/go/docker.mk index 8155706..8f02f8b 100644 --- a/make/go/docker.mk +++ b/make/go/docker.mk @@ -12,32 +12,11 @@ $(call _assert_var,DOCKER_ORG) # Must be set $(call _assert_var,DOCKER_PROJECT) -DOCKER_WORKSPACE_IMAGE := $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace -DOCKER_WORKSPACE_FILE := Dockerfile.workspace -DOCKER_WORKSPACE_DIR := /workspace - # Settable DOCKER_BINS ?= # Settable DOCKER_BUILD_EXTRA_FLAGS ?= -# Runtime -DOCKERMAKETARGET ?= all - -.PHONY: dockerbuildworkspace -dockerbuildworkspace: - docker build \ - $(DOCKER_BUILD_EXTRA_FLAGS) \ - --build-arg PROJECT=$(PROJECT) \ - --build-arg GO_MODULE=$(GO_MODULE) \ - -t $(DOCKER_WORKSPACE_IMAGE) \ - -f $(DOCKER_WORKSPACE_FILE) \ - . - -.PHONY: dockermakeworkspace -dockermakeworkspace: dockerbuildworkspace - docker run -v "$(CURDIR):$(DOCKER_WORKSPACE_DIR)" $(DOCKER_WORKSPACE_IMAGE) make -j 8 $(DOCKERMAKETARGET) - .PHONY: dockerbuild dockerbuild::