Skip to content

Commit

Permalink
Remove redundant docker cache dir
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed May 3, 2024
1 parent 0599ff0 commit a1aad55
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions Makefile-os
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ DOCKER_TAG := addons-server-test
DOCKER_PLATFORM := linux/amd64
DOCKER_PROGRESS := auto
DOCKER_COMMIT := $(shell git rev-parse HEAD)
DOCKER_CACHE_DIR := docker-cache

export DOCKER_VERSION ?= local
export DOCKER_COMMIT ?= $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -61,13 +60,6 @@ DOCKER_BUILD_ARGS := -t $(DOCKER_TAG) \
--progress=$(DOCKER_PROGRESS) \
--builder=$(DOCKER_BUILDER) \
--label git.commit=$(DOCKER_COMMIT) \
--cache-to=type=local,dest=$(DOCKER_CACHE_DIR)-new \

DOCKER_CACHE_INDEX = $(wildcard $(DOCKER_CACHE_DIR)/index.json)

ifneq ($(DOCKER_CACHE_INDEX),)
DOCKER_BUILD_ARGS += --cache-from=type=local,src=$(DOCKER_CACHE_DIR),mode=max
endif

.PHONY: version
version: ## create version.json file
Expand All @@ -76,14 +68,11 @@ version: ## create version.json file
.PHONY: build_docker_image
build_docker_image: create_docker_builder version ## Build the docker image
DOCKER_BUILDKIT=1 docker buildx build $(DOCKER_BUILD_ARGS) .
rm -rf $(DOCKER_CACHE_DIR)
mv $(DOCKER_CACHE_DIR)-new $(DOCKER_CACHE_DIR)

.PHONY: clean_docker
clean_docker: ## Clean up docker containers, images, caches, volumes and local cache directories. Use with caution. To restart the app run make initialize_docker after this commandUse with caution.
docker compose down --rmi all --volumes
docker rmi $(DOCKER_TAG) || true
rm -rf $(DOCKER_CACHE_DIR)
docker compose down --rmi local --volumes
docker buildx prune -af
rm -rf ./deps/**

.PHONY: initialize_docker
Expand Down

0 comments on commit a1aad55

Please sign in to comment.