-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (46 loc) · 2.11 KB
/
Makefile
File metadata and controls
59 lines (46 loc) · 2.11 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
NAME = dockerbase/openssh-server
VERSION = 1.1
.PHONY: all build test tag_latest release ssh
all: build
build:
docker build -t $(NAME):$(VERSION) --rm .
test:
#env NAME=$(NAME) VERSION=$(VERSION) ./test/runner.sh
docker run -it --rm $(NAME):$(VERSION) echo hello world!
run:
docker run --name $(subst /,-,$(NAME)) --restart=always -t --cidfile cidfile -d $(NAME):$(VERSION) /sbin/runit
start:
docker start `cat cidfile`
stop:
docker stop -t 10 `cat cidfile`
rm:
docker rm `cat cidfile`
rm -fr cidfile
version:
docker run -it --rm $(NAME):$(VERSION) sh -c " lsb_release -d ; git --version ; ssh -V " | tee COMPONENTS
dos2unix COMPONENTS
sed -i -e 's/^/ /' COMPONENTS
sed -i -e '/^### Components & Versions/q' README.md
echo >> README.md
cat COMPONENTS >> README.md
rm COMPONENTS
tag_latest:
docker tag $(NAME):$(VERSION) $(NAME):latest
@echo "*** Don't forget to create a tag. git tag rel-$(VERSION) && git push origin rel-$(VERSION)"
release: test tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
#@if ! head -n 1 Changelog.md | grep -q 'release date'; then echo 'Please note the release date in Changelog.md.' && false; fi
docker push $(NAME)
@echo "*** Don't forget to create a tag. git tag rel-$(VERSION) && git push origin rel-$(VERSION)"
ssh:
chmod 600 build/insecure_key
@ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \
if test "$$ID" = ""; then echo "Container is not running."; exit 1; fi && \
IP=$$(docker inspect $$ID | grep IPAddr | sed 's/.*: "//; s/".*//') && \
echo "SSHing into $$IP" && \
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i build/insecure_key root@$$IP
enter:
@ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \
if test "$$ID" = ""; then echo "Container is not running."; exit 1; fi && \
PID=$$(docker inspect --format {{.State.Pid}} $$ID) && \
SHELL=/bin/bash sudo -E build/bin/nsenter --target $$PID --mount --uts --ipc --net --pid