Skip to content

Commit 9f5ed58

Browse files
didomdfcoding
authored andcommitted
Split dev container targets (pypi#10834)
For all our in-container dev actions, we don't need to build both the web container and the static container for all of them. Also adds some missing targets.
1 parent 1cd4e5a commit 9f5ed58

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

Makefile

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,26 @@ default:
1717
@echo
1818
@exit 1
1919

20-
.state/docker-build: Dockerfile package.json package-lock.json requirements/main.txt requirements/deploy.txt
21-
# Build our docker containers for this project.
20+
.state/docker-build-web: Dockerfile package.json package-lock.json requirements/main.txt requirements/deploy.txt requirements/lint.txt requirements/docs.txt requirements/dev.txt requirements/tests.txt
21+
# Build our web container for this project.
2222
docker-compose build --build-arg IPYTHON=$(IPYTHON) --force-rm web
23-
docker-compose build --force-rm worker
23+
24+
# Mark the state so we don't rebuild this needlessly.
25+
mkdir -p .state
26+
touch .state/docker-build-web
27+
28+
.state/docker-build-static: Dockerfile package.json package-lock.json .babelrc
29+
# Build our static container for this project.
2430
docker-compose build --force-rm static
2531

32+
# Mark the state so we don't rebuild this needlessly.
33+
mkdir -p .state
34+
touch .state/docker-build-static
35+
36+
.state/docker-build: .state/docker-build-web .state/docker-build-static
37+
# Build the worker container for this project
38+
docker-compose build --force-rm worker
39+
2640
# Mark the state so we don't rebuild this needlessly.
2741
mkdir -p .state
2842
touch .state/docker-build
@@ -35,52 +49,52 @@ build:
3549
serve: .state/docker-build
3650
docker-compose up --remove-orphans
3751

38-
debug: .state/docker-build
52+
debug: .state/docker-build-web
3953
docker-compose run --rm --service-ports web
4054

41-
tests: .state/docker-build
55+
tests: .state/docker-build-web
4256
docker-compose run --rm web bin/tests --postgresql-host db $(T) $(TESTARGS)
4357

44-
static_tests: .state/docker-build
58+
static_tests: .state/docker-build-static
4559
docker-compose run --rm static bin/static_tests $(T) $(TESTARGS)
4660

47-
static_pipeline: .state/docker-build
61+
static_pipeline: .state/docker-build-static
4862
docker-compose run --rm static bin/static_pipeline $(T) $(TESTARGS)
4963

50-
reformat: .state/docker-build
64+
reformat: .state/docker-build-web
5165
docker-compose run --rm web bin/reformat
5266

53-
lint: .state/docker-build
67+
lint: .state/docker-build-web
5468
docker-compose run --rm web bin/lint && bin/static_lint
5569

56-
docs: .state/docker-build
70+
docs: .state/docker-build-web
5771
docker-compose run --rm web bin/docs
5872

59-
licenses: .state/docker-build
73+
licenses: .state/docker-build-web
6074
docker-compose run --rm web bin/licenses
6175

62-
deps: .state/docker-build
76+
deps: .state/docker-build-web
6377
docker-compose run --rm web bin/deps
6478

65-
translations: .state/docker-build
79+
translations: .state/docker-build-web
6680
docker-compose run --rm web bin/translations
6781

6882
requirements/%.txt: requirements/%.in
6983
docker-compose run --rm web bin/pip-compile --allow-unsafe --generate-hashes --output-file=$@ $<
7084

71-
initdb:
85+
initdb: .state/docker-build-web
7286
docker-compose run --rm web psql -h db -d postgres -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname ='warehouse';"
7387
docker-compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS warehouse"
7488
docker-compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'"
7589
xz -d -f -k dev/$(DB).sql.xz --stdout | docker-compose run --rm web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f -
7690
docker-compose run --rm web python -m warehouse db upgrade head
91+
docker-compose run --rm web python -m warehouse sponsors populate-db
7792
$(MAKE) reindex
78-
docker-compose run web python -m warehouse sponsors populate-db
7993

80-
reindex:
94+
reindex: .state/docker-build-web
8195
docker-compose run --rm web python -m warehouse search reindex
8296

83-
shell:
97+
shell: .state/docker-build-web
8498
docker-compose run --rm web python -m warehouse shell
8599

86100
clean:

0 commit comments

Comments
 (0)