-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenDocker.sh
More file actions
executable file
·71 lines (54 loc) · 1.44 KB
/
genDocker.sh
File metadata and controls
executable file
·71 lines (54 loc) · 1.44 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
#!/bin/bash
# Script-Name : genDocker.sh
# Author : Daniel Weise
# Company : Concepts and Training
# Email : daniel.weise@conceptsandtrainings.de
# args?
if [ $# -lt 2 ]
then
echo "Usage: $0 <name> <target path>"
exit 1
fi
# set variables
name=$1
target=$2
path=${target}/${name}
# dir exists?
[ -d ${path} ] && echo "Dir allready exists. Abort..." && exit 1
# create dirs
mkdir -p ${path}/build
# error while creating dir
[ $? -ne 0 ] && echo "Directory ${path}/build cant be created. Abort..." && exit 1
#create files
touch ${path}/docker-compose.yml
[ $? -ne 0 ] && echo "File ${path}/docker-compose.yml cant be created. Abort..." && exit 1
touch ${path}/build/Dockerfile
[ $? -ne 0 ] && echo "File ${path}/Dockerfile cant be created. Abort..." && exit 1
touch ${path}/build/startup.sh
[ $? -ne 0 ] && echo "File ${path}/startup.sh cant be created. Abort..." && exit 1
# fill the docker-compose.yml
cat << EOF > ${path}/docker-compose.yml
version: '2'
services:
ilias-web:
build: ./build
# Define ports here <hostport>:<containerport>
# ports:
# Define volumes here <hostvolume>:<containervolume>
# volumes:
# Set container env vars
# environment:
EOF
# fill the Dockerfile
cat << EOF > ${path}/build/Dockerfile
FROM debian:jessie
RUN apt-get update
COPY startup.sh /startup.sh
RUN chmod +x /startup.sh
CMD /startup.sh
EOF
# fill the file startup.sh
cat << EOF > ${path}/build/startup.sh
#!/bin/bash
echo "Hello World"
EOF