-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-alpine.sh
42 lines (33 loc) · 1.08 KB
/
nginx-alpine.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
MODULES_TO_ADD_LIST=""
IMAGE_NAME_GENERATED=""
BASE_NGINX_IMAGE="nginx:mainline-alpine"
# Get the current folder and check if .env file exists before sourcing it
dir="$(dirname "$0")"
if [ -f "$dir/.env" ]; then
source "$dir/.env"
fi
# Check if the environnement variables are set
if [ -z "${MODULES_TO_ADD_LIST}" ]; then
echo "MODULES_TO_ADD_LIST is not set"
exit 1
else
MODULES_TO_ADD_LIST=${MODULES_TO_ADD_LIST}
fi
if [ -z "${IMAGE_NAME_GENERATED}" ]; then
echo "IMAGE_NAME_GENERATED is not set"
exit 1
else
IMAGE_NAME_GENERATED=${IMAGE_NAME_GENERATED}
fi
# Copy the Dockerfile that will get the module on the host
curl https://raw.githubusercontent.com/nginxinc/docker-nginx/master/modules/Dockerfile.alpine > Dockerfile.build.temp
# Run the dockerfile to generate the clean image with modules
export DOCKER_BUILDKIT=1
docker build -f Dockerfile.build.temp \
--build-arg ENABLED_MODULES="$MODULES_TO_ADD_LIST" \
--build-arg NGINX_FROM_IMAGE="$BASE_NGINX_IMAGE" \
-t "$IMAGE_NAME_GENERATED" \
.
# Delete the Dockerfile
rm Dockerfile.build.temp