forked from hoteltonight/ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·38 lines (30 loc) · 1.06 KB
/
build.sh
File metadata and controls
executable file
·38 lines (30 loc) · 1.06 KB
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
#!/bin/bash
set -euo pipefail
# Enter version/s to build
VERSIONS_TO_BUILD=("3.4")
TAG_TO_FIND="ENV RUBY_VERSION"
# Enter the ID of AWS ECR registry
# Main - 709657315391
# SLR - 820223782446
NAME="709657315391.dkr.ecr.eu-west-1.amazonaws.com/ruby-jemalloc"
# NAME="709657315391.dkr.ecr.eu-west-1.amazonaws.com/ruby-jemalloc"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
for version in "${VERSIONS_TO_BUILD[@]}"; do
dockerfiles=$(find "$SCRIPT_DIR/$version" -name Dockerfile)
while IFS= read -r dockerfile; do
[[ "$dockerfile" == *onbuild* || "$dockerfile" == *alpine* ]] && continue
full_version=$(grep "$TAG_TO_FIND" "$dockerfile" | awk '{print $3}')
base="${dockerfile#*$version/}"
base="${base%/Dockerfile}"
base="${base//\//-}"
final_tag="${full_version}-${base}"
image_name="${NAME}:${final_tag}"
echo "Building $image_name"
(
cd "$(dirname "$dockerfile")"
docker build --platform linux/amd64 -t "$image_name" .
# Uncomment to push:
# docker push "$image_name"
)
done <<< "$dockerfiles"
done