Skip to content

Commit f1acde3

Browse files
committed
chore: abstract scripts
1 parent ce7d9d3 commit f1acde3

11 files changed

+95
-68
lines changed

.github/workflows/base.yml

+8-13
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,30 @@ on:
55
paths:
66
- "base/**"
77

8+
env:
9+
IMAGE: base
10+
VERSION: 1
11+
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
12+
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
13+
814
jobs:
915
build:
1016
runs-on: ${{ matrix.os }}
1117

1218
strategy:
13-
fail-fast: false
1419
matrix:
15-
node-version: [10.x]
1620
os: [ubuntu-latest, windows-latest]
1721

1822
steps:
1923
- uses: actions/checkout@v1
20-
- name: Build the Docker image
21-
run: |
22-
cd base
23-
bash build.sh
24+
- run: bash build.sh
2425
env:
2526
CI_PLATFORM: ${{ matrix.os }}
26-
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
27-
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_TOKEN }}
2827

2928
manifest:
3029
needs: build
3130
runs-on: ubuntu-latest
3231

3332
steps:
3433
- uses: actions/checkout@v1
35-
- name: Build the Docker manifest
36-
run: bash base/manifest.sh
37-
env:
38-
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
39-
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_TOKEN }}
34+
- run: bash manifest.sh

.github/workflows/rabbitmq.yml

+20-21
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,29 @@ on:
66
- "rabbitmq/**"
77

88
env:
9-
RABBITMQ_VERSION: 3.8.6
9+
IMAGE: rabbitmq
10+
VERSION: 3.8.6
11+
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
12+
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
1013

1114
jobs:
1215
build:
13-
runs-on: windows-2019
14-
defaults:
15-
run:
16-
shell: bash
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest, windows-latest]
21+
1722
steps:
1823
- uses: actions/checkout@v1
19-
# - uses: satackey/[email protected]
20-
- name: build
21-
run: |
22-
cd rabbitmq
23-
docker build --build-arg VERSION=$RABBITMQ_VERSION --file Dockerfile.windows --tag exivity/rabbitmq:$RABBITMQ_VERSION .
24-
docker tag exivity/rabbitmq:$RABBITMQ_VERSION exivity/rabbitmq:latest
25-
- name: test
26-
run: ./rabbitmq/test.sh
27-
- name: login
28-
run: echo $DOCKER_HUB_TOKEN | docker login -u $DOCKER_HUB_USER --password-stdin
24+
- run: bash build.sh
2925
env:
30-
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
31-
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
32-
- name: push
33-
run: |
34-
docker push exivity/rabbitmq:$RABBITMQ_VERSION
35-
docker push exivity/rabbitmq:latest
26+
CI_PLATFORM: ${{ matrix.os }}
27+
28+
manifest:
29+
needs: build
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v1
34+
- run: bash manifest.sh

base/Dockerfile.windows

+4-3
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
7474
if ($sig.Status -ne 'Valid') { Write-Error 'Authenticode signature is not valid' } ; `
7575
Write-Output $sig.SignerCertificate.Thumbprint ; `
7676
if (@( `
77-
'7E253367F8A102A91D04829E37F3410F14B68A5F', `
78-
'AF764E1EA56C762617BDC757C8B0F3780A0CF5F9' `
77+
'795D68C6828BD3D21B36EB15F7A31EE5873EBE8F' `
7978
) -notcontains $sig.SignerCertificate.Thumbprint) { Write-Error 'Unknown signer certificate' } ; `
8079
Start-Process msiexec.exe -ArgumentList '/i', 'yarn.msi', '/quiet', '/norestart' -NoNewWindow -Wait
8180

81+
# Install Git for Windows
82+
# source: https://github.com/StefanScherer/dockerfiles-windows/blob/9d3eb757d73a455908af9a1cab350ed7f36d49db/node/10/nano/Dockerfile
8283
ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-busybox-64-bit.zip
83-
ENV GIT_SHA256 9817ab455d9cbd0b09d8664b4afbe4bbf78d18b556b3541d09238501a749486c
84+
ENV GIT_SHA256 1D879A5AEA154676CD2BE8B947DCDFC0991F82B72DD5116A31146BAC923B7CCA
8485

8586
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
8687
Invoke-WebRequest -UseBasicParsing $env:GIT_DOWNLOAD_URL -OutFile git.zip; `

base/build.sh

-13
This file was deleted.

base/manifest.sh

-15
This file was deleted.

build.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
cd $IMAGE
4+
5+
if [[ $CI_PLATFORM == 'ubuntu-latest' ]]; then
6+
PLATFORM=linux
7+
elif [[ $CI_PLATFORM == 'windows-latest' ]]; then
8+
PLATFORM=windows
9+
fi
10+
11+
DOCKERFILE=Dockerfile.$PLATFORM
12+
VERSION_TAG=$VERSION-$PLATFORM
13+
LATEST_TAG=latest-$PLATFORM
14+
15+
docker build \
16+
--build-arg VERSION=$VERSION
17+
--file "$DOCKERFILE" \
18+
--tag exivity/$IMAGE:$VERSION_TAG \
19+
.
20+
21+
docker tag exivity/$IMAGE:$VERSION_TAG exivity/$IMAGE:$LATEST_TAG
22+
23+
echo $DOCKER_HUB_TOKEN | docker login -u $DOCKER_HUB_USER --password-stdin
24+
docker push exivity/$IMAGE:$VERSION_TAG
25+
docker push exivity/$IMAGE:$LATEST_TAG
26+

manifest.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
export DOCKER_CLI_EXPERIMENTAL=enabled
4+
5+
# Version
6+
docker manifest create "exivity/$IMAGE:$VERSION" \
7+
"exivity/$IMAGE:$VERSION-linux" \
8+
"exivity/$IMAGE:$VERSION-windows"
9+
10+
# Latest
11+
docker manifest create "exivity/$IMAGE:latest" \
12+
"exivity/$IMAGE:latest-linux" \
13+
"exivity/$IMAGE:latest-windows"
14+
15+
echo $DOCKER_HUB_TOKEN | docker login -u $DOCKER_HUB_USER --password-stdin
16+
17+
docker manifest push "exivity/$IMAGE:$VERSION"
18+
docker manifest push "exivity/$IMAGE:latest"

rabbitmq/Dockerfile.linux

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM rabbitmq
2+
3+
COPY healthcheck.sh /usr/local/bin/
4+
5+
HEALTHCHECK CMD ["healthcheck.sh"]

rabbitmq/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# exivity/rabbitmq
22

3-
Docker image of Rabbit MQ server (Windows only).
3+
Docker image of Rabbit MQ server.
44

55
## Usage
66

rabbitmq/healthcheck.cmd

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
REM curl --connect-timeout 5 --max-time 60 --retry 1 --user guest:guest http://localhost:15672/api/healthchecks/node
2-
31
cd "C:/Program Files/RabbitMQ Server/rabbitmq_server-%VERSION%/sbin"
42
rabbitmqctl.bat ping

rabbitmq/healthcheck.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
# https://github.com/docker-library/healthcheck/blob/master/rabbitmq/docker-healthcheck
4+
5+
# A RabbitMQ node is considered healthy if all the below are true:
6+
# * the rabbit app finished booting & it's running
7+
# ~* there are no alarms~
8+
# ~* there is at least 1 active listener~
9+
10+
rabbitmqctl eval '
11+
{ true, rabbit_app_booted_and_running } = { rabbit:is_booted(node()), rabbit_app_booted_and_running },
12+
rabbitmq_node_is_healthy.
13+
' || exit 1

0 commit comments

Comments
 (0)