Skip to content

Commit 8e8882b

Browse files
committed
Added makefile
Added Makefile for easier development with most common commands
1 parent 10921b8 commit 8e8882b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# Makefile
3+
# to build image easier
4+
#
5+
6+
IMAGE_NAME=slocomptech/openvpn
7+
DATA_DIR=$(shell pwd)/data
8+
CONTAINER=ovpn
9+
10+
11+
default: build
12+
13+
#
14+
# Build docker image
15+
#
16+
build:
17+
@echo "Building image"
18+
docker build \
19+
--build-arg BUILD_DATE=$(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\") \
20+
--build-arg VCS_REF="$(shell git rev-parse --short HEAD)" \
21+
--build-arg VCS_SRC="https://github.com/SloCompTech/docker-openvpn/commit/$(shell git rev-parse HEAD)" \
22+
--build-arg VERSION=latest \
23+
-t ${IMAGE_NAME} .
24+
25+
#
26+
# Run setup command
27+
# Opens temporary container to setup environment
28+
#
29+
config:
30+
@echo "Running temporary container"
31+
mkdir -p data
32+
docker run -it --rm --cap-add NET_ADMIN -v ${DATA_DIR}:/config ${IMAGE_NAME}:latest bash
33+
34+
#
35+
# Setups & starts real container
36+
# Run only once, then use docker start|stop|restart|exec
37+
#
38+
setup:
39+
@echo "Running temporary container"
40+
docker run -it --cap-add NET_ADMIN -p 1194:1194/udp -v ${DATA_DIR}:/config --name ${CONTAINER} ${IMAGE_NAME}:latest
41+
42+
#
43+
# Starts container
44+
#
45+
start:
46+
docker start ${CONTAINER}
47+
48+
#
49+
# Stops container
50+
#
51+
stop:
52+
docker stop ${CONTAINER}
53+
54+
#
55+
# Restart container
56+
#
57+
restart:
58+
docker restart ${CONTAINER}
59+
60+
#
61+
# Open terminal inside container
62+
# Only when container is running
63+
#
64+
term:
65+
docker exec -it ${CONTAINER} bash

0 commit comments

Comments
 (0)