Skip to content

Commit 93f9afd

Browse files
2 parents f142e5b + 62efe78 commit 93f9afd

File tree

6 files changed

+544
-471
lines changed

6 files changed

+544
-471
lines changed

.env.example

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
REGISTRY_URL=1234.dkr.ecr.us-east-1.amazonaws.com
1+
#REGISTRY_URL=1234.dkr.ecr.us-east-1.amazonaws.com
2+
REGISTRY_URL=https://index.docker.io/v1/
23
APP_NAME=appname
3-
TAG=latest
4-
EMAIL=thisismysingingvoice@acme.co
5-
URL=https://acme.co
4+
IMAGE=centos
5+
TAG=7.8.2003
66
USER=apiuser
77
PASSWORD=apiuserpassword
8-
VERBOSE=false
8+
EMAIL=thisismysingingvoice@acme.co
9+
HOST=localhost
910
OVERWRITE=true
11+
PORT=1812
1012
PORT=80
13+
PORT2=18120
14+
URL=https://acme.co
15+
VERBOSE=false

jupyter/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ decorator==5.1.1 ; python_full_version == "3.10.7"
88
entrypoints==0.4 ; python_full_version == "3.10.7"
99
executing==1.1.1 ; python_full_version == "3.10.7"
1010
ipykernel==6.16.0 ; python_full_version == "3.10.7"
11-
ipython==8.5.0 ; python_full_version == "3.10.7"
11+
ipython==8.10.0 ; python_full_version == "3.10.7"
1212
jedi==0.18.1 ; python_full_version == "3.10.7"
1313
jupyter-client==7.4.4 ; python_full_version == "3.10.7"
14-
jupyter-core==4.11.1 ; python_full_version == "3.10.7"
14+
jupyter-core==4.11.2 ; python_full_version == "3.10.7"
1515
matplotlib-inline==0.1.6 ; python_full_version == "3.10.7"
1616
nest-asyncio==1.5.6 ; python_full_version == "3.10.7"
1717
numpy==1.23.4 ; python_full_version == "3.10.7"

justfile

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
set dotenv-load
55

66
# set env var
7-
export APP := "compose_image_name"
7+
export APP := `echo ${APP_NAME}`
88
export CPU := "2"
9-
export IMAGE := `echo ${REGISTRY_URL}/it
9+
export IMAGE := `echo ${IMAGE}`
1010
export MEM := "2048"
1111
export NS := "default"
1212
export PROF := "minikube"
1313
export SHELL := "/bin/bash"
14+
export SCRIPT := "harden"
15+
export SHELL := "/bin/bash"
16+
export TAG := `echo ${TAG}`
1417
VERSION := `cat VERSION`
1518

1619
# x86_64/arm64
@@ -23,6 +26,7 @@ host := `uname -n`
2326
default:
2427
just --list
2528

29+
# TODO: setup tilt
2630
# [devspace] start minikube + devspace
2731
start-devspace:
2832
#!/usr/bin/env bash
@@ -39,76 +43,110 @@ start-devspace:
3943
stop-devspace:
4044
minikube stop -p {{PROF}}
4145

42-
# [docker] build locally
43-
build:
44-
#!/usr/bin/env bash
45-
# set -euxo pipefail
46+
# docker-compose / docker compose
47+
# * https://docs.docker.com/compose/install/linux/#install-using-the-repository
48+
docker-compose := if `command -v docker-compose; echo $?` == "0" {
49+
"docker-compose"
50+
} else {
51+
"docker compose"
52+
}
4653

47-
echo "building ${APP_NAME}:${TAG}"
54+
# [halp] list available commands
55+
default:
56+
just --list
4857

49-
if [[ {{arch}} == "arm64" ]]; then
50-
docker build -f Dockerfile -t it/${APP_NAME}:${TAG} --build-arg CHIPSET_ARCH=aarch64-linux-gnu .
58+
# [check] lint sh script
59+
checkbash:
60+
#!/usr/bin/env bash
61+
checkbashisms {{SCRIPT}}
62+
if [[ $? -eq 1 ]]; then
63+
echo "bashisms found. Exiting..."
64+
exit 1
5165
else
52-
docker build -f Dockerfile -t it/${APP_NAME}:${TAG} --build-arg CHIPSET_ARCH=x86_64-linux-gnu .
66+
echo "No bashisms found"
5367
fi
5468

55-
echo "created tag it/${APP_NAME}:${TAG} {{IMAGE}}/${APP_NAME}:${TAG}"
56-
57-
# TODO: QA
58-
# [docker] intel build
59-
buildx:
60-
docker buildx build -f Dockerfile --progress=plain -t ${TAG} --build-arg CHIPSET_ARCH=x86_64-linux-gnu --load .
61-
62-
# [docker] build w/docker-compose defaults
63-
build-nc:
69+
# [docker] build locally or on intel box
70+
build: checkbash
6471
#!/usr/bin/env bash
65-
# set -euxo pipefail
72+
set -euxo pipefail
73+
if [[ {{arch}} == "arm64" ]]; then
74+
docker build -f Dockerfile -t {{APP}} --build-arg CHIPSET_ARCH=aarch64-linux-gnu .
75+
else
76+
docker build -f Dockerfile --progress=plain -t {{APP}} .
77+
fi
6678

79+
# [docker] arm build w/docker-compose defaults
80+
build-clean: checkbash
81+
#!/usr/bin/env bash
82+
set -euxo pipefail
6783
if [[ {{arch}} == "arm64" ]]; then
68-
docker-compose build --pull --no-cache --build-arg CHIPSET_ARCH=aarch64-linux-gnu
84+
{{docker-compose}} build --pull --no-cache --build-arg CHIPSET_ARCH=aarch64-linux-gnu --parallel
6985
else
70-
docker-compose build --pull --no-cache --build-arg CHIPSET_ARCH=x86_64-linux-gnu
86+
{{docker-compose}} build --pull --no-cache --parallel
7187
fi
7288

73-
# [docker] pull latest image
74-
pull:
75-
docker pull {{IMAGE}}/${APP_NAME}:${TAG}
89+
# [docker] login to registry (exit code 127 == 0)
90+
login:
91+
#!/usr/bin/env bash
92+
# set -euxo pipefail
93+
echo "Log into ${REGISTRY_URL} as ${USER_NAME}. Please enter your password: "
94+
cmd=$(docker login --username ${USER_NAME} ${REGISTRY_URL})
95+
if [[ $("$cmd" >/dev/null 2>&1; echo $?) -ne 127 ]]; then
96+
echo 'Not logged into Docker. Exiting...'
97+
exit 1
98+
fi
99+
100+
# [docker] tag image as latest
101+
tag-latest:
102+
docker tag {{APP}}:latest {{IMAGE}}/{{APP}}:latest
76103

77-
# [docker] run local image
78-
run: pull
79-
docker run -it --rm -v $(pwd):/app {{IMAGE}}/${APP_NAME}:${TAG} {{SHELL}}
104+
# [docker] tag latest image from VERSION file
105+
tag-version:
106+
@echo "create tag {{APP}}:{{VERSION}} {{IMAGE}}/{{APP}}:{{VERSION}}"
107+
docker tag {{APP}} {{IMAGE}}/{{APP}}:{{VERSION}}
108+
109+
# [docker] push latest image
110+
push: login
111+
docker push {{IMAGE}}/{{APP}}:{{TAG}}
112+
113+
# [docker] pull latest image
114+
pull: login
115+
docker pull {{IMAGE}}/{{APP}}
80116

81-
# [docker] push latest image to ecr
82-
release:
117+
# [docker] run container
118+
run: build
83119
#!/usr/bin/env bash
84120
# set -euxo pipefail
85-
86-
AWS_DEFAULT_PROFILE=bastion.use1 aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REGISTRY_URL}
87-
docker push {{IMAGE}}/${APP_NAME}:${TAG}
121+
docker run --rm -it \
122+
--name {{APP}} \
123+
--env-file .env \
124+
--entrypoint={{SHELL}} \
125+
-h ${HOST:-localhost} \
126+
-v $(pwd)/conf:/etc/duoauthproxy \
127+
-p ${PORT:-1812}:${PORT:-1812/udp} \
128+
-p ${PORT2:-18120}:${PORT2:-18120/udp} \
129+
--cap-drop=all \
130+
--cap-add=setgid \
131+
--cap-add=setuid \
132+
{{APP}}
88133

89134
# [docker] start docker-compose container
90-
start:
91-
docker-compose up -d
135+
up: build
136+
{{docker-compose}} up -d
137+
138+
# [docker] get running container logs
139+
logs:
140+
{{docker-compose}} logs -tf --tail="50" {{APP}}
92141

93142
# [docker] ssh into container
94143
exec:
95-
docker-compose exec {{APP}} {{SHELL}}
144+
docker exec -it {{APP}} {{SHELL}}
96145

97146
# [docker] stop docker-compose container
98147
stop:
99-
docker-compose stop
148+
{{docker-compose}} stop
100149

101150
# [docker] remove docker-compose container(s) and networks
102151
down: stop
103-
docker-compose down --remove-orphans
104-
105-
# [docker] tag image as latest
106-
tag-latest:
107-
@echo "create tag it/${APP_NAME}:${TAG} {{IMAGE}}/${APP_NAME}:${TAG}"
108-
docker tag it/${APP_NAME}:${TAG} {{IMAGE}}/${APP_NAME}:${TAG}
109-
110-
# TODO: QA
111-
# [docker] tag image from VERSION file
112-
tag-version:
113-
@echo "create tag it/${APP_NAME}:{{VERSION}} {{IMAGE}}/${APP_NAME}:${TAG}"
114-
docker tag it/${APP_NAME}:{{VERSION}} {{IMAGE}}/${APP_NAME}:${TAG}
152+
{{docker-compose}} down --remove-orphans

markdown/just.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# justfile
2+
3+
> [just](https://just.systems/man/en/chapter_1.html) is a handy way to save and run project-specific commands.
4+
>
5+
> Commands, called recipes, are stored in a file called justfile with syntax inspired by make:
6+
7+
## [Install](https://just.systems/man/en/chapter_4.html)
8+
```bash
9+
# macOS
10+
brew install just
11+
12+
# Ubuntu/Debian
13+
curl -q 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null
14+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list
15+
sudo apt update
16+
sudo apt install just -y
17+
```
18+
19+
## Usage
20+
```bash
21+
# default commands
22+
just
23+
24+
# custom directives
25+
just buildx # [docker] intel build
26+
just pull # [docker] pull latest image
27+
just run # [docker] run local image
28+
just up # [docker] start docker-compose container
29+
just down # [docker] remove docker-compose container(s) and networks
30+
```

0 commit comments

Comments
 (0)