This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·103 lines (89 loc) · 2.14 KB
/
run
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
98
99
100
101
102
103
#!/bin/bash
DEFAULT_OUTPUT=${PWD}/build.tar;
TAG=hackthe6ix/landing-2021;
WORKING_DIR=/usr/var/app;
NAME=owo;
function dev() {
while getopts r:s:v:p: flag
do
case "${flag}" in
# static folder
r) r=${OPTARG};;
# src folder
s) s=${OPTARG};;
# docker tag version
v) v=${OPTARG};;
# host port to run on
p) p=${OPTARG};;
esac
done
local tag=$TAG\:${v:-latest};
docker build --target development -t $tag .;
docker run \
-v ${PWD}/static:${r:-$WORKING_DIR/static} \
-v ${PWD}/src:${s:-$WORKING_DIR/src} \
-p ${p:-8080}:8080 \
-it $tag;
}
function test() {
while getopts r:s:v: flag
do
case "${flag}" in
# static folder
r) r=${OPTARG};;
# src folder
s) s=${OPTARG};;
# docker tag version
v) v=${OPTARG};;
esac
done
local tag=$TAG:${v:-latest};
docker build --target testing -t $tag .;
docker run \
-v ${PWD}/static:${r:-$WORKING_DIR/static} \
-v ${PWD}/src:${s:-$WORKING_DIR/src} \
$tag;
}
function export() {
while getopts v:o: flag
do
case "${flag}" in
# docker tag version
v) v=${OPTARG};;
# output file/dir
o) o=${OPTARG};;
esac
done
local output=${o:-$DEFAULT_OUTPUT};
if [[ $output == *.tar ]]
then
type=tar;
else
type=local;
fi
DOCKER_BUILDKIT=1 docker build \
--output type=$type,dest=$output \
--target 'export' \
-t $TAG\:${v:-latest} .;
}
function serve() {
while getopts v:o:p: flag
do
case "${flag}" in
# docker tag version
v) v=${OPTARG};;
# Server name
o) o=${OPTARG};;
# Port to run from
p) p=${OPTARG};;
esac
done
local tag=$TAG\:${v:-latest};
local port=${p:-80};
docker build --target deploy -t $tag .;
docker run \
-p ${port}:80 \
-e SERVER_NAME=${o:-_} \
$tag;
}
eval "$@ && exit 0";