-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_init.sh
executable file
·42 lines (39 loc) · 1.06 KB
/
local_init.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
#!/bin/bash
if hash docker 2>/dev/null; then
echo "✅ Docker is installed"
else
echo "❌ Docker is not installed"
exit 1
fi
if [ -f .env ]; then
# Load Environment Variables
echo "✅ Loading environment variabled"
export $(cat .env | grep -v '#' | sed 's/\r$//' | awk '/=/ {print $1}' )
else
echo "❌ Could not find .env file, rename .env.template and populate the file"
exit 1
fi
if [ -f "$GIT_SSH_KEY" ]; then
echo "✅ Copying GIT SSH key file to ${PWD}"
cp "${GIT_SSH_KEY}" ./git.pem
else
echo "❌ $GIT_SSH_KEY does not exist, exiting setup."
exit 1
fi
docker build \
--build-arg email=$GIT_EMAIL \
--build-arg name=$GIT_NAME \
--build-arg sls_key=$SERVERLESS_KEY \
-t $CONTAINER_NAME \
.
docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
docker run \
-d \
-v volume_$CONTAINER_NAME:/home/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
-p $VSCODE_PORT:3000 \
--name "${CONTAINER_NAME}" \
"${CONTAINER_NAME}"
docker logs "${CONTAINER_NAME}"
rm -Rf ./git.pem