-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_type_yaml.sh
executable file
·72 lines (64 loc) · 1.97 KB
/
make_type_yaml.sh
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
#!/bin/bash
TYPE=$1
CONFIG_DIR=../ts-ra-config
CONFIG_FILE=$(echo ${CONFIG_DIR}/config.${TYPE}.json)
API_PORT=$(cat $CONFIG_FILE | jq --raw-output '.APIPORT')
COLLECTION=$(cat $CONFIG_FILE | jq --raw-output '.COLLECTION')
MK=$(which minikube)
if [ $MK ]; then
echo "HAVE minikube";
MKURL=$(minikube service ${TYPE}-backend-service --url)
echo MKURL is $MKURL
END_POINT=$(echo ${MKURL} | awk -F '//' '{print $2}')
echo endpoint is $END_POINT
API_IP=$(echo ${END_POINT} | awk -F: '{print $1}')
echo API_ip is $API_IP
API_PORT=$(echo ${END_POINT} | awk -F: '{print $2}')
echo API_port is $API_PORT
VITE_TYPE=${TYPE}
else
API_IP=$(./backend_address.sh ${COLLECTION})
CONFIG_FILE=$(echo $CONFIG_DIR/config.${TYPE}.json)
API_PORT=$(cat $CONFIG_FILE | jq --raw-output '.APIPORT')
VITE_TYPE=$(cat $CONFIG_FILE | jq --raw-output '.ITEM_NAME')
fi
JQSTRING=$(echo -n .config.${TYPE})
PORT=$(cat package.json | jq -r ${JQSTRING})
echo TYPE is $TYPE AND JQSTRING iS ${JQSTRING} AND PORT is $PORT AND API_IP is $API_IP and API_PORT is $API_PORT and VITE_TYPE is $VITE_TYPE
cat <<EOF > compose.yaml.${TYPE}
services:
${TYPE}_frontend:
container_name: ${TYPE}_frontend
build: .
ports:
- "${PORT}:${PORT}"
environment:
SSL_CERT: "/certs/localhost.crt"
SSL_KEY: "/certs/localhost.key"
VITE_API_IP: "${API_IP}"
VITE_API_PORT: "${API_PORT}"
VITE_TYPE: "${VITE_TYPE}"
EOF
cat <<EOF2 > Dockerfile
FROM node:latest
ARG SSL_CERT
ENV SSL_CERT ${SSL_CERT}
ARG SSL_KEY
ENV SSL_KEY ${SSL_KEY}
ARG API_IP
ENV API_IP ${API_IP}
ARG API_PORT
ENV API_PORT ${API_PORT}
ARG TYPE
ENV TYPE ${TYPE}
RUN apt update
RUN apt install -y git npm
RUN mkdir /certs
ADD ./certs/ /certs
RUN mkdir /src
RUN git clone https://github.com/robertwilkinson9/ts-ra-config.git /src/ts-ra-config
RUN git clone https://github.com/robertwilkinson9/ts-reserve-assets.git /src/ts-reserve-assets
WORKDIR /src/ts-reserve-assets
RUN npm install
CMD [ "npm", "run", "generic", ${TYPE} ]
EOF2