|
16 | 16 | # under the License. |
17 | 17 |
|
18 | 18 | IMAGE_NAME = df-site-build |
19 | | -REPO_NAME = infrastructure-actions |
20 | 19 |
|
21 | | -.PHONY: clone-repo sync-repo build-image build |
| 20 | +.PHONY: build clean |
22 | 21 |
|
23 | | -all: build |
24 | | - |
25 | | -# clones the infrastructure-actions repository |
26 | | -clone-repo: |
27 | | - @if [ ! -d "$(REPO_NAME)" ]; then \ |
28 | | - echo "Cloning $(REPO_NAME)..."; \ |
29 | | - git clone --depth 1 https://github.com/apache/infrastructure-actions.git $(REPO_NAME); \ |
30 | | - else \ |
31 | | - echo "$(REPO_NAME) already exists, skipping clone."; \ |
32 | | - fi |
33 | | - |
34 | | -# syncs the repository with the latest changes from the main branch |
35 | | -sync-repo: clone-repo |
36 | | - @cd $(REPO_NAME) && \ |
37 | | - if [ -n "$$(git status --porcelain)" ]; then \ |
38 | | - echo "Error: Repository has uncommitted changes. Please clean the repository first."; \ |
39 | | - exit 1; \ |
40 | | - fi; \ |
41 | | - echo "Syncing with origin/main..."; \ |
42 | | - git fetch origin main && \ |
43 | | - git checkout main |
44 | | - |
45 | | - |
46 | | -# builds the Docker image with pelicanasf installed |
47 | | -build-image: |
| 22 | +# runs the Docker container to build the site |
| 23 | +build: |
48 | 24 | @if ! docker image inspect $(IMAGE_NAME) > /dev/null 2>&1; then \ |
49 | | - echo "Building Docker image $(IMAGE_NAME)..."; \ |
50 | | - docker build -t $(IMAGE_NAME) $(REPO_NAME)/pelican; \ |
51 | | - else \ |
52 | | - echo "Docker image $(IMAGE_NAME) already exists, skipping build."; \ |
| 25 | + docker build -t $(IMAGE_NAME) https://github.com/apache/infrastructure-actions.git#main:pelican; \ |
53 | 26 | fi |
54 | | - |
55 | | -# runs the Docker container to build the site |
56 | | -build: sync-repo build-image |
57 | 27 | docker run -it --rm -p8000:8000 -v $(PWD):/site --entrypoint /bin/bash $(IMAGE_NAME) -c \ |
58 | 28 | "pelicanasf content -o blog && python3 -m http.server 8000" |
| 29 | + |
| 30 | +# removes the Docker image |
| 31 | +clean: |
| 32 | + @if docker image inspect $(IMAGE_NAME) > /dev/null 2>&1; then \ |
| 33 | + docker image rm -f $(IMAGE_NAME) > /dev/null 2>&1 && \ |
| 34 | + echo "Removed Docker image $(IMAGE_NAME)."; \ |
| 35 | + fi |
0 commit comments