Skip to content

Commit 3d42f0e

Browse files
committed
WIP: make scratch directory in a better location
and also MAC compatible
1 parent 52b0ad3 commit 3d42f0e

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

Makefile

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ $(COMMON_SRC_DEPS_ORIGIN) $(SERVICE_SRC_DEPS_ORIGIN) $(ONPREM_SRC_DEPS_ORIGIN):
4545

4646
COMPARE_TO_BRANCH ?= origin/main
4747

48-
SCRATCH_DIR := /private/tmp/scratch/
48+
SCRATCH_DIR := $(HOME)/.cache/osbuild-getting-started/scratch
49+
export SCRATCH_DIR
4950
COMMON_DIR := podman/image-builder-config
5051
CLI_DIRS := podman/weldr podman/cloudapi podman/dnf-json
5152
DATA_DIR := data/s3/service
52-
ALL_SCRATCH_DIRS := $(addprefix $(SCRATCH_DIR),$(COMMON_DIR) $(CLI_DIRS) $(DATA_DIR))
53+
ALL_SCRATCH_DIRS := $(addprefix $(SCRATCH_DIR)/,$(COMMON_DIR) $(CLI_DIRS) $(DATA_DIR))
5354

5455
# internal rule for sub-calls
5556
# NOTE: This chowns all directories back - as we expect to run partly as root
@@ -74,7 +75,7 @@ service_sub_make_frontend:
7475
service_sub_make_cleanup:
7576
@for DIR in $(COMMON_SRC_DEPS_ORIGIN) $(SERVICE_SRC_DEPS_ORIGIN); do echo "Giving directory permissions in '$$DIR' back to '$(SUDO_USER)'"; chown -R $(SUDO_USER): $$DIR || sudo chown -R $(SUDO_USER): $$DIR; done
7677
@echo "Your current versions are (comparing to origin/main):"
77-
bash -c './git_stack.sh'
78+
bash -c './tools/git_stack.sh'
7879

7980
.PHONY: service_sub_makes_no_frontend
8081
service_sub_makes_no_frontend: service_sub_make_backend service_sub_make_cleanup
@@ -88,7 +89,7 @@ onprem_sub_makes:
8889
$(MAKE_SUB_CALL) -C $(SRC_DEPS_EXTERNAL_CHECKOUT_DIR)weldr-client container
8990
@for DIR in $(COMMON_SRC_DEPS_ORIGIN) $(ONPREM_SRC_DEPS_ORIGIN); do echo "Giving directory permissions in '$$DIR' back to '$(SUDO_USER)'"; chown -R $(SUDO_USER): $$DIR || sudo chown -R $(SUDO_USER): $$DIR; done
9091
@echo "Your current versions are (comparing to origin/main):"
91-
./git_stack.sh
92+
bash -c './tools/git_stack.sh'
9293

9394
.PHONY: service_containers
9495
service_containers: $(COMMON_SRC_DEPS_ORIGIN) $(SERVICE_SRC_DEPS_ORIGIN) common_sub_makes service_sub_makes service_images_built.info
@@ -100,13 +101,13 @@ onprem_containers: $(COMMON_SRC_DEPS_ORIGIN) $(ONPREM_SRC_DEPS_ORIGIN) common_su
100101

101102
service_images_built.info: service/config/Dockerfile-config service/config/composer/osbuild-composer.toml $(ALL_SCRATCH_DIRS)
102103
# building remaining containers (config, fauxauth)
103-
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose.yml build --build-arg CONFIG_BUILD_DATE=$(shell date -r $(SCRATCH_DIR)$(COMMON_DIR) +%Y%m%d_%H%M%S)
104+
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose.yml build --build-arg CONFIG_BUILD_DATE=$(shell date -r $(SCRATCH_DIR)/$(COMMON_DIR) +%Y%m%d_%H%M%S)
104105
echo "Images last built on" > $@
105106
date >> $@
106107

107108
onprem_images_built.info: service/config/Dockerfile-config-onprem service/config/composer/osbuild-composer-onprem.toml $(ALL_SCRATCH_DIRS)
108109
# building remaining containers (config)
109-
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose-onprem.yml build --build-arg CONFIG_BUILD_DATE=$(shell date -r $(SCRATCH_DIR)$(COMMON_DIR) +%Y%m%d_%H%M%S)
110+
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose-onprem.yml build --build-arg CONFIG_BUILD_DATE=$(shell date -r $(SCRATCH_DIR)/$(COMMON_DIR) +%Y%m%d_%H%M%S)
110111
echo "Images last built on" > $@
111112
date >> $@
112113

@@ -116,23 +117,25 @@ $(ALL_SCRATCH_DIRS):
116117

117118
.PHONY: wipe_config
118119
wipe_config:
119-
sudo rm -rf $(SCRATCH_DIR)$(COMMON_DIR)
120+
sudo rm -rf $(SCRATCH_DIR)/$(COMMON_DIR)
120121
rm -f $(SRC_DEPS_EXTERNAL_CHECKOUT_DIR)image-builder-frontend/node_modules/.cache/webpack-dev-server/server.pem
121122

122123
.PHONY: clean
123124
clean: $(COMMON_SRC_DEPS_ORIGIN) $(SERVICE_SRC_DEPS_ORIGIN) $(ONPREM_SRC_DEPS_ORIGIN) prune_service prune_onprem wipe_config
124125
rm -f service_images_built.info
125126
rm -f onprem_images_built.info
126-
sudo rm -rf $(SCRATCH_DIR)
127+
rm -rf $(SCRATCH_DIR) || (echo "Trying as root" ;sudo rm -rf $(SCRATCH_DIR))
127128
for DIR in $*; do $(MAKE_SUB_CALL) -C $$DIR clean; done
128-
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose.yml rm
129-
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose-onprem.yml rm
129+
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose.yml down --volumes
130+
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose.yml rm --volumes
131+
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose-onprem.yml down --volumes
132+
$(CONTAINER_COMPOSE_EXECUTABLE) -f service/docker-compose-onprem.yml rm --volumes
130133

131134
# for compatibility of relative volume mount paths
132135
# between docker and podman we have to change to the directory
133136
.PHONY: run_service
134137
.ONESHELL:
135-
run_service: $(addprefix $(SCRATCH_DIR),$(COMMON_DIRS)) service_containers
138+
run_service: $(addprefix $(SCRATCH_DIR)/,$(COMMON_DIRS)) service_containers
136139
export PORTS="$(shell docker compose -f service/docker-compose.yml config|grep -Po '(?<=published: ")[0-9]+')"
137140
echo "-- Checking if any of our ports are used: $$PORTS"
138141
sudo netstat -lntp|grep -E "$$(echo "$$PORTS"|tr ' ' ':')"
@@ -168,10 +171,10 @@ prune_onprem:
168171
# between docker and podman we have to change to the directory
169172
.PHONY: run_onprem
170173
.ONESHELL:
171-
run_onprem: $(addprefix $(SCRATCH_DIR),$(COMMON_DIRS) $(CLI_DIRS)) onprem_containers
174+
run_onprem: $(addprefix $(SCRATCH_DIR)/,$(COMMON_DIRS) $(CLI_DIRS)) onprem_containers
172175
cd service
173176
echo "Remove dangling sockets as root"
174-
sudo rm -f $(addsuffix /api.sock*, $(addprefix $(SCRATCH_DIR), $(CLI_DIRS)))
177+
sudo rm -f $(addsuffix /api.sock*, $(addprefix $(SCRATCH_DIR)/, $(CLI_DIRS)))
175178
$(CONTAINER_COMPOSE_EXECUTABLE) -f docker-compose-onprem.yml up -d
176179
@echo "------ Welcome to osbuild! You can now use 'composer-cli' to build images"
177180
@echo " … and 'exit' afterwards"
@@ -191,8 +194,9 @@ docs: docs/src_compile_service.svg docs/src_compile_onprem.svg
191194
overview:
192195
@echo "Fetching all repos for better overview if rebase will be necessary:"
193196
ifeq (${SUDO_USER},$(shell whoami))
194-
./git_stack.sh fetch --all
197+
bash -c './tools/git_stack.sh fetch --all'
195198
else
196-
sudo -u ${SUDO_USER} ./git_stack.sh fetch --all
199+
sudo -u ${SUDO_USER} bash -c './tools/git_stack.sh fetch --all'
197200
endif
198-
@./git_stack.sh
201+
@bash -c './tools/git_stack.sh'
202+

service/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ volumes:
1010
driver_opts:
1111
type: none
1212
# this can be modified as desired
13-
device: /private/tmp/scratch/podman/image-builder-config
13+
device: ${SCRATCH_DIR:-/scratch}/podman/image-builder-config
1414
o: bind
1515

1616
services:
@@ -194,7 +194,7 @@ services:
194194
image: docker.io/minio/minio:latest
195195
volumes:
196196
# this can be modified as desired
197-
- /private/tmp/scratch/data/s3:/data:z
197+
- ${SCRATCH_DIR:-/scratch}/data/s3:/data:z
198198
command: server /data --console-address ":9090"
199199
working_dir: /data
200200
environment:

git_stack.sh renamed to tools/git_stack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# repos to respect
4-
BASEDIR=$(dirname $(readlink -f $0))/..
4+
BASEDIR=$(dirname $(readlink -f $0))/../..
55
REPOS="osbuild-getting-started osbuild osbuild-composer images image-builder image-builder-frontend weldr-client"
66
REPOS="$REPOS pulp-client community-gateway"
77

0 commit comments

Comments
 (0)