-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (91 loc) · 3.42 KB
/
Makefile
File metadata and controls
113 lines (91 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Makefile for OpenCA docker dev
# (c) 2021-2023 by Massimiliano Pala and OpenCA Labs
# All Rights Reserved
# Includes the details for the docker image
-include .env
# NOW auxiliary variable
NOW := $(shell date +%Y%m%d)
# Repository information
REPO_OWNER := openca
REPO_PUSH_ACCOUNT := opencrypto
REPO_NAME := docker-dev
# Phony targets
.PHONY: help all ubuntu ubuntu24/base ubuntu24/oqs ubuntu24/libpki dev
help:
@echo
@echo " Usage: make [ all | devenv-base[/nocache] | devenv-crypto[/nocache] | devenv-libpki | scripts ]"
@echo
@exit 1
all: ubuntu
devenv-base:: ubuntu24/base
devenv-base/nocache: NOCACHE=no-cache
devenv-base/nocache: ubuntu24/base
ubuntu24/base:: ubuntu24/base/build
@echo "Default base image; no push performed."
ubuntu24/base/build::
@bin/build-openca-devenv ubuntu24 n $(NOCACHE)
@mkdir -p ~/.dockercompose && \
cp Docker/docker-compose-ubuntu24.yml ~/.dockercompose/
ubuntu24/base/push: SRC_TAG=ghcr.io/$(REPO_OWNER)/ubuntu24:latest
ubuntu24/base/push: DST_TAG_BASE=ghcr.io/$(REPO_OWNER)/devenv-base
ubuntu24/base/push: docker-push
devenv-crypto:: ubuntu24/crypto
devenv-crypto/nocache: NOCACHE=no-cache
devenv-crypto/nocache: ubuntu24/crypto
ubuntu24/crypto:: ubuntu24/crypto/build ubuntu24/crypto/push
ubuntu24/crypto/build::
@bin/build-openca-devenv ubuntu24-crypto n $(NOCACHE)
@mkdir -p ~/.dockercompose && \
cp Docker/docker-compose-ubuntu24-crypto.yml ~/.dockercompose/
ubuntu24/crypto/push: SRC_TAG=ghcr.io/$(REPO_OWNER)/ubuntu24-crypto:latest
ubuntu24/crypto/push: DST_TAG_BASE=ghcr.io/$(REPO_OWNER)/devenv-crypto
ubuntu24/crypto/push: docker-push
devenv-libpki:: ubuntu24/libpki
ubuntu24/libpki:: ubuntu24/libpki/build ubuntu24/libpki/push
ubuntu24/libpki/build::
@bin/build-openca-devenv ubuntu24-libpki n $(NOCACHE)
@mkdir -p ~/.dockercompose && \
cp Docker/docker-compose-ubuntu24-libpki.yml ~/.dockercompose/
ubuntu24/libpki/push: SRC_TAG=ghcr.io/openca/devenv-crypto:latest
ubuntu24/libpki/push: DST_TAG_BASE=ghcr.io/$(REPO_OWNER)/devenv-libpki
ubuntu24/libpki/push: docker-push
docker-push:
@echo ""
@echo "Logging in to GitHub Container Registry (GITHUB_PAT)..." ; \
if [ "x$(GITHUB_PAT)" = "x" ] ; then \
if [ -f ~/.github_pat ] ; then \
GITHUB_PAT=$$(cat ~/.github_pat*) ; \
else \
echo "Error: GitHub PAT not provided. Set GITHUB_PAT variable or create ~/.github_pat file." ; \
exit 1 ; \
fi ; \
fi ; \
echo $$GITHUB_PAT | docker login ghcr.io -u $(REPO_PUSH_ACCOUNT) --password-stdin && \
echo "Logged in successfully." ; \
echo ""
@echo "Pushing the Docker image to GitHub repository (TAG=$(SRC_TAG) ...)" ; \
if [ "x$(DST_TAG_BASE)" != "x" ] ; then \
docker image tag "$(SRC_TAG)" "$(DST_TAG_BASE):latest" ; \
docker image tag "$(SRC_TAG)" "$(DST_TAG_BASE):$(NOW)" ; \
else \
DST_TAG_BASE=$(SRC_TAG) ; \
echo "Using source tag as destination: $$DST_TAG_BASE" ; \
fi ; \
docker push "$(DST_TAG_BASE):$(NOW)" && \
docker push "$(DST_TAG_BASE):latest"
@echo "Docker image pushed successfully."
@echo ""
scripts:
@target_dir=~/bin; \
if ! [ -d "$$target_dir" ]; then \
target_dir=~/.bin ; \
if ! [ -d "$$target_dir" ]; then \
echo "Creating target directory: $$target_dir"; \
mkdir -p "$$target_dir" ; \
fi; \
fi ; \
echo && echo "Copying scripts to the local directory ($$target_dir)..." ; \
cp -r bin/openca-devenv "$$target_dir"/
@echo ""
@echo "Please make sure to add the target directory to your PATH variable."
@echo ""