Skip to content
This repository was archived by the owner on Jan 11, 2025. It is now read-only.

Commit 22a6e93

Browse files
fixing and optimizing scripts
1 parent 6bc2f58 commit 22a6e93

File tree

4 files changed

+70
-73
lines changed

4 files changed

+70
-73
lines changed

docker-build.sh

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,46 @@ function build() {
2525
return
2626
fi
2727

28-
VCS_REF=$(git rev-parse --short HEAD)
29-
docker build --build-arg BUILD_DATE=$(date +%Y%m%d%H%M%S) --build-arg BUILD_VERSION=$(date +%s) --build-arg VCS_REF=$VCS_REF -t fabiocicerchia/nginx-lua:$PATCH-$OS$OS_VER -f $DOCKERFILE .
30-
IMAGE_ID=$(docker image ls -q fabiocicerchia/nginx-lua:$PATCH-$OS$OS_VER)
31-
28+
TAGS="-t fabiocicerchia/nginx-lua:$PATCH-$OS$OS_VER"
3229
if [ "$VER_TAGS$OS_TAGS$DEFAULT" == "111" ]; then
33-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$MAJOR
34-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$MINOR
35-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$PATCH
36-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:latest
30+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$MAJOR"
31+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$MINOR"
32+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$PATCH"
33+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:latest"
3734
fi
3835

3936
if [ "$VER_TAGS$OS_TAGS" == "11" ]; then
40-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$MAJOR-$OS
41-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$MAJOR-$OS$OS_VER
37+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$MAJOR-$OS"
38+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$MAJOR-$OS$OS_VER"
4239
fi
4340

4441
if [ "$OS_TAGS" == "1" ]; then
45-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$MINOR-$OS
46-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$PATCH-$OS
47-
docker tag $IMAGE_ID fabiocicerchia/nginx-lua:$MINOR-$OS$OS_VER
42+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$MINOR-$OS"
43+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$PATCH-$OS"
44+
TAGS="$TAGS -t fabiocicerchia/nginx-lua:$MINOR-$OS$OS_VER"
4845
fi
46+
47+
BUILD_DATE=$(date +%Y%m%d%H%M%S)
48+
BUILD_VERSION=$(date +%s)
49+
VCS_REF=$(git rev-parse --short HEAD)
50+
docker build \
51+
--build-arg BUILD_DATE=$BUILD_DATE \
52+
--build-arg BUILD_VERSION=$BUILD_VERSION \
53+
--build-arg VCS_REF=$VCS_REF \
54+
$TAGS \
55+
-f $DOCKERFILE .
4956
}
5057

5158
set -x
5259

5360
OS=$1
5461
VERSIONS=()
55-
if [ "$OS" == "alpine" ]; then VERSIONS=$ALPINE
56-
elif [ "$OS" == "amazonlinux" ]; then VERSIONS=$AMAZONLINUX
57-
elif [ "$OS" == "centos" ]; then VERSIONS=$CENTOS
58-
elif [ "$OS" == "debian" ]; then VERSIONS=$DEBIAN
59-
elif [ "$OS" == "fedora" ]; then VERSIONS=$FEDORA
60-
elif [ "$OS" == "ubuntu" ]; then VERSIONS=$UBUNTU
62+
if [ "$OS" == "alpine" ]; then VERSIONS=("${ALPINE[@]}")
63+
elif [ "$OS" == "amazonlinux" ]; then VERSIONS=("${AMAZONLINUX[@]}")
64+
elif [ "$OS" == "centos" ]; then VERSIONS=("${CENTOS[@]}")
65+
elif [ "$OS" == "debian" ]; then VERSIONS=("${DEBIAN[@]}")
66+
elif [ "$OS" == "fedora" ]; then VERSIONS=("${FEDORA[@]}")
67+
elif [ "$OS" == "ubuntu" ]; then VERSIONS=("${UBUNTU[@]}")
6168
fi
6269

6370
NLEN=${#NGINX[@]}

docker-generate.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

docker-push.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ function push() {
2121
MINOR=$MAJOR.$(echo $NGINX_VER | cut -d '.' -f 2)
2222
PATCH=$NGINX_VER
2323

24-
docker_tag_exists fabiocicerchia/nginx-lua $MAJOR-$OS$OS_VER || docker push fabiocicerchia/nginx-lua:$MAJOR-$OS$OS_VER
25-
docker_tag_exists fabiocicerchia/nginx-lua $MINOR-$OS$OS_VER || docker push fabiocicerchia/nginx-lua:$MINOR-$OS$OS_VER
26-
docker_tag_exists fabiocicerchia/nginx-lua $PATCH-$OS$OS_VER || docker push fabiocicerchia/nginx-lua:$PATCH-$OS$OS_VER
27-
2824
if docker_tag_exists fabiocicerchia/nginx-lua $PATCH-$OS$OS_VER; then
2925
return
3026
fi
3127

28+
docker push fabiocicerchia/nginx-lua:$MAJOR-$OS$OS_VER
29+
docker push fabiocicerchia/nginx-lua:$MINOR-$OS$OS_VER
30+
docker push fabiocicerchia/nginx-lua:$PATCH-$OS$OS_VER
31+
3232
if [ "$VER_TAGS$OS_TAGS$DEFAULT" == "111" ]; then
3333
docker push fabiocicerchia/nginx-lua:$MAJOR
3434
docker push fabiocicerchia/nginx-lua:$MINOR

dockerfile-generate.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
source supported_versions
4+
5+
function init_dockerfile() {
6+
DOCKERFILE_PATH=nginx/$NGINX_VER/$OS/$OS_VER
7+
DOCKERFILE=$DOCKERFILE_PATH/Dockerfile
8+
9+
mkdir -p $DOCKERFILE_PATH 2> /dev/null
10+
cp tpl/Dockerfile.$OS $DOCKERFILE
11+
12+
sed -i "" "s/{{DOCKER_IMAGE}}/fabiocicerchia\/nginx-lua/" $DOCKERFILE
13+
sed -i "" "s/{{DOCKER_IMAGE_OS}}/$OS/" $DOCKERFILE
14+
sed -i "" "s/{{DOCKER_IMAGE_TAG}}/$OS_VER/" $DOCKERFILE
15+
sed -i "" "s/{{VER_NGINX}}/$NGINX_VER/" $DOCKERFILE
16+
}
17+
18+
set -x
19+
20+
for NGINX_VER in "${NGINX[@]}"; do
21+
22+
OS=alpine
23+
for OS_VER in "${ALPINE[@]}"; do init_dockerfile; done
24+
25+
OS=amazonlinux
26+
for OS_VER in "${AMAZONLINUX[@]}"; do init_dockerfile; done
27+
28+
OS=centos
29+
for OS_VER in "${CENTOS[@]}"; do init_dockerfile; done
30+
31+
OS=debian
32+
for OS_VER in "${DEBIAN[@]}"; do init_dockerfile; done
33+
34+
OS=fedora
35+
for OS_VER in "${FEDORA[@]}"; do init_dockerfile; done
36+
37+
OS=ubuntu
38+
for OS_VER in "${UBUNTU[@]}"; do init_dockerfile; done
39+
40+
done

0 commit comments

Comments
 (0)