Skip to content

Commit

Permalink
feat: mount gomod caching
Browse files Browse the repository at this point in the history
Signed-off-by: osamamagdy <[email protected]>
  • Loading branch information
osamamagdy committed May 17, 2024
1 parent 73067b7 commit 2a38c61
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- uses: dorny/paths-filter@v3
id: filter
with:
Expand All @@ -53,16 +56,16 @@ jobs:
run: |
DOCKER_BUILD_OPTS="--build-arg UBUNTU_VERSION=${{ matrix.os-version }} --build-arg UBUNTU_NAME=${{ matrix.os-name }}" \
make -C utils/docker pull pull-dev
- name: run make inside dev container
env:
DOCKER_DEV_CI_MODE: 1
DOCKER_QUIET_BUILD: 1
run: |
run: |
DOCKER_BUILD_OPTS="--build-arg UBUNTU_VERSION=${{ matrix.os-version }} --build-arg UBUNTU_NAME=${{ matrix.os-name }}" \
GOMODCACHE_PATH=$(go env GOMODCACHE) \
make -C utils/docker run-dev DOCKER_DEV_OPTIONAL_CMD='env IS_CI_RUNNING=true \
make all'
#
# continue only if we push to main and rebuild docker images
#
Expand Down
3 changes: 3 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ DOCKER_CMD := docker
# - DOCKER_BASE_RT_IMAGE_APT_ADD_PKGS (for all infrastructure containers)
# - DOCKER_BASE_DEV_IMAGE_APT_ADD_PKGS (for all images which build fabric/fpc code)
# - DOCKER_DEV_IMAGE_APT_ADD_PKGS (for dev image)
# - You can mount your local go mod cache directory
# to that of the docker image which allows caching of the dependencies and faster builds
# - GOMODCACHE_PATH (the path of your local go packages usually known by `go env GOMODCACHE`)


# SGX related settings
Expand Down
7 changes: 7 additions & 0 deletions utils/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,18 @@ endif
# allows to override with `buildx build`
DOCKER_BUILD_CMD ?= build

# allows to mount host gomodcache into the container
GOMODCACHE_PATH ?=
DOCKER_GOMODCACHE=/project/pkg/mod

# Docker run options
# ------------------
DOCKER_DEV_RUN_OPTS ?=
DOCKER_DEV_RUN_OPTS += --rm
# - mount local gomodcache from the host
ifneq ($(GOMODCACHE_PATH),)
DOCKER_DEV_RUN_OPTS += -v "$(GOMODCACHE_PATH)":"$(DOCKER_GOMODCACHE)"
endif
# - import docker daemon socket (so dev container can run docker)
DOCKER_DEV_RUN_OPTS += -v "$(DOCKER_DAEMON_SOCKET)":"$(DOCKER_SOCKET)"
# - mount local fpc repo into the dev container so development inside container is
Expand Down

0 comments on commit 2a38c61

Please sign in to comment.