-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontainer-dockerhub.sh
executable file
·51 lines (41 loc) · 1.79 KB
/
container-dockerhub.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
#!/usr/bin/env sh
# -----------------------------------------------------------------------------
# Docker Build, Tag & Push Container for DockerHub
# -----------------------------------------------------------------------------
# Author : Dwi Fahni Denni (@zeroc0d3)
# License : Apache v2
# -----------------------------------------------------------------------------
export PATH_COMPOSE='compose'
export PATH_DOCKER='docker'
export CONTAINER_ALPINE="cicd-alpine"
export CONTAINER_UBUNTU="cicd-ubuntu"
export CONTAINER_CODEBUILD="cicd-codebuild"
export IMAGE="devopscorner/cicd"
cd $PATH_COMPOSE/$PATH_DOCKER/$CONTAINER_ALPINE
echo "Build Image => $IMAGE:alpine"
docker build --no-cache -f Dockerfile -t $IMAGE:alpine .
cd ../../../
cd $PATH_COMPOSE/$PATH_DOCKER/$CONTAINER_UBUNTU
echo "Build Image => $IMAGE:ubuntu"
docker build --no-cache -f Dockerfile -t $IMAGE:ubuntu .
cd ../../../
cd $PATH_COMPOSE/$PATH_DOCKER/$CONTAINER_CODEBUILD
echo "Build Image => $IMAGE:codebuild"
docker build --no-cache -f Dockerfile -t $IMAGE:codebuild .
cd ../../../
cd $PATH_COMPOSE
# ./dockerhub-tag.sh devopscorner/cicd [alpine|ubuntu|codebuild] [version|latest|tags] [custom-tags]
./dockerhub-tag.sh devopscorner/cicd alpine 3.16
./dockerhub-tag.sh devopscorner/cicd ubuntu 22.04
./dockerhub-tag.sh devopscorner/cicd codebuild 4.0
# ./dockerhub-push.sh devopscorner/cicd [alpine|ubuntu|codebuild|version|latest|tags|custom-tags]
./dockerhub-push.sh devopscorner/cicd latest
./dockerhub-push.sh devopscorner/cicd alpine
./dockerhub-push.sh devopscorner/cicd ubuntu
./dockerhub-push.sh devopscorner/cicd codebuild
echo ""
echo "Cleanup Unknown Tags"
echo "docker images -a | grep none | awk '{ print $3; }' | xargs docker rmi"
docker images -a | grep none | awk '{ print $3; }' | xargs docker rmi
echo ""
echo "-- ALL DONE --"