-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.py
97 lines (79 loc) · 3.12 KB
/
build.py
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
import argparse
import os
import sys
from generator import Generator
# Create the parser
my_parser = argparse.ArgumentParser(description='Generate script to Build Base')
# Add the arguments
my_parser.add_argument('PHP_Version',
metavar='version',
type=str,
help='The PHP Version')
my_parser.add_argument('--debug',
dest='Debug',
nargs="?",
const=True,
default=False,
help='Enable Debug Build (multiple layers)')
my_parser.add_argument('--arch',
dest='arch',
default="amd64,arm64,s390x",
help='Build Base')
my_parser.add_argument('--build-base',
dest='buildBase',
nargs="?",
const="base",
default="",
help='Build Base')
my_parser.add_argument('--build-cli',
dest='buildCli',
nargs="?",
const="cli",
default="",
help='Build Cli')
my_parser.add_argument('--build-fpm',
dest='buildFpm',
nargs="?",
const="fpm",
default="",
help='Build Fpm')
my_parser.add_argument('--build-fpm-apache',
dest='buildFpmApache',
nargs="?",
const="fpm_apache",
default="",
help='Build fpm-apache')
my_parser.add_argument('--build-fpm-nginx',
dest='buildFpmNginx',
nargs="?",
const="fpm_nginx",
default="",
help='Build Fpm-nginx')
my_parser.add_argument('--build-nginx',
dest='buildNginx',
nargs="?",
const="nginx",
default="",
help='Build nginx')
my_parser.add_argument('--push',
dest='push',
nargs="?",
const="push",
default="",
help='Push the image to the docker.io repository')
# Execute the parse_args() method
args = my_parser.parse_args()
gen = Generator(args.PHP_Version, args.Debug, args.push != "")
cmd_list = []
cmd_list.append(args.buildBase) if args.buildBase != "" else None
cmd_list.append(args.buildCli) if args.buildCli != "" else None
cmd_list.append(args.buildFpm) if args.buildFpm != "" else None
cmd_list.append(args.buildFpmApache) if args.buildFpmApache != "" else None
cmd_list.append(args.buildFpmNginx) if args.buildFpmNginx != "" else None
cmd_list.append(args.buildNginx) if args.buildNginx != "" else None
for cmd in cmd_list:
gen.manifest_create(cmd)
for arch in args.arch.split(","):
iid = getattr(gen, "build_" + cmd)(arch)
gen.manifest_add(iid, cmd, arch)
gen.manifest_push(cmd)