-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerise.sh
executable file
·124 lines (93 loc) · 3.74 KB
/
dockerise.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -e
# --- BASE BUILD CONFIG
SHOULD_BUILD_BASE=true
# Use tag instead of branch for published builds
OPENMSUPPLY_BRANCH='V1-beta-buildtest'
# Use tag instead of branch for published builds
REMOTE_SERVER_BRANCH='V1-beta-buildtest'
# msupplyfoundation would be dockerhub account
NEW_IMAGE_NAME='msupplyfoundation/omsupply'
NEW_IMAGE_TAG="be-${REMOTE_SERVER_BRANCH}_fe-${OPENMSUPPLY_BRANCH}"
NODE_VERSION='16'
# --- BUILD WITH DATA CONFIG
SHOULD_BUILD_WITH_DATA=true
NEW_IMAGE_WITH_DATA_NAME='msupplyfoundation/omsupply_withdata'
NEW_IMAGE_WITH_DATA_TAG="${NEW_IMAGE_TAG}"
# To access localhost from within docker container use host.docker.internal
SYNC_URL="http://host.docker.internal:2048"
SYNC_SITE_NAME="demo"
SYNC_SITE_PASSWORD="pass"
SYNC_SITE_ID="2"
USERS="central admin:pass,hospital director:pass,rural pharm:pass"
# ---- COMBINED CONFIG
# Also create latest tag, i.e. omsupply:latest and omsupply_withdata:latest
TAG_AS_LATEST=true
# Push to dockerhub
PUSH_TO_DOCKERHUB=false
# ---- REBUILDING FLAGS
# Increment any value to force rebuild (i.e. when branch names haven't changed but new changes were pushed to that branch or entrypoint changed etc..)
FORCE_REBUILD_REMOTE_SERVER='0'
FORCE_REBUILD_OPENMSUPPLY_CLIENT='0'
FORCE_REBUILD_CONFIGURATIONS='0'
FORCE_REBUILD_ENTRY='0'
FORCE_REBUILD_WITH_DATA='0'
# --- BASE BUILD
if $SHOULD_BUILD_BASE; then
NEW_IMAGE_NAME_AND_TAG="${NEW_IMAGE_NAME}:${NEW_IMAGE_TAG}"
echo -e "\nBuilding image: ${NEW_IMAGE_NAME_AND_TAG}\n"
docker build \
--progress plain \
-t "${NEW_IMAGE_NAME_AND_TAG}" \
--build-arg REMOTE_SERVER_BRANCH="$REMOTE_SERVER_BRANCH" \
--build-arg OPENMSUPPLY_BRANCH="$OPENMSUPPLY_BRANCH" \
--build-arg NODE_VERSION="$NODE_VERSION" \
--build-arg FORCE_REBUILD_REMOTE_SERVER="$FORCE_REBUILD_REMOTE_SERVER" \
--build-arg FORCE_REBUILD_OPENMSUPPLY_CLIENT="$FORCE_REBUILD_OPENMSUPPLY_CLIENT" \
--build-arg FORCE_REBUILD_CONFIGURATIONS="$FORCE_REBUILD_CONFIGURATIONS" \
docker/build_empty/.
if $PUSH_TO_DOCKERHUB; then
docker push "${NEW_IMAGE_NAME_AND_TAG}"
fi
if $TAG_AS_LATEST; then
echo -e "\nTaggins as latest: ${NEW_IMAGE_NAME}:latest\n"
docker tag $NEW_IMAGE_NAME_AND_TAG "${NEW_IMAGE_NAME}:latest"
if $PUSH_TO_DOCKERHUB; then
docker push "${NEW_IMAGE_NAME}:latest"
fi
fi
# For ease of testing new local images
docker tag $NEW_IMAGE_NAME_AND_TAG "new"
fi
# -- BUILD WITH DATA
if $SHOULD_BUILD_WITH_DATA; then
NEW_IMAGE_NAME_AND_TAG="${NEW_IMAGE_WITH_DATA_NAME}:${NEW_IMAGE_WITH_DATA_TAG}"
echo -e "\nBuilding image: ${NEW_IMAGE_NAME_AND_TAG}\n"
docker build \
--progress plain \
-t "${NEW_IMAGE_NAME_AND_TAG}" \
--build-arg BASE_IMAGE_NAME="$NEW_IMAGE_NAME" \
--build-arg BASE_IMAGE_TAG="$NEW_IMAGE_TAG" \
--build-arg SYNC_URL="$SYNC_URL" \
--build-arg SYNC_SITE_NAME="$SYNC_SITE_NAME" \
--build-arg SYNC_SITE_PASSWORD="$SYNC_SITE_PASSWORD" \
--build-arg SYNC_SITE_ID="$SYNC_SITE_ID" \
--build-arg USERS="$USERS" \
--build-arg FORCE_REBUILD_WITH_DATA="$FORCE_REBUILD_WITH_DATA" \
docker/build_with_central_data/.
if $PUSH_TO_DOCKERHUB; then
docker push "${NEW_IMAGE_NAME_AND_TAG}"
fi
if $TAG_AS_LATEST; then
docker tag $NEW_IMAGE_NAME_AND_TAG "${NEW_IMAGE_WITH_DATA_NAME}:latest"
if $PUSH_TO_DOCKERHUB; then
docker push "${NEW_IMAGE_WITH_DATA_NAME}:latest"
fi
fi
# For ease of testing new local images
docker tag $NEW_IMAGE_NAME_AND_TAG "new_withdata"
fi
# --build-arg substitues the ARG variables in Dockerfile
# --no-cache -> can be used to re-build (rebuilds the whole image, can also use FORCE_REBUILD args)
# --progress plain -> show full progress
# --platform -> can be used when targeting other systems, i.e. "linux/amd64"