Skip to content

Commit

Permalink
feat: monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed Aug 12, 2020
1 parent 97a750d commit d6c3a85
Show file tree
Hide file tree
Showing 16 changed files with 236 additions and 62 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker Image CI

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node-version: [10.x]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v1
- name: Build the Docker image
run: bash base/build.sh
env:
CI_PLATFORM: ${{ matrix.os }}
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_TOKEN }}

manifest:
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Build the Docker manifest
run: bash base/manifest.sh
env:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_TOKEN }}
34 changes: 0 additions & 34 deletions .github/workflows/docker.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/rabbitmq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build CI

on: [push]

env:
RABBITMQ_VERSION: 3.8.6

jobs:
build:
runs-on: windows-2019
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v1
# - uses: satackey/action-docker-layer-caching@v0.0.5
- name: build
run: |
cd rabbitmq
docker build --build-arg VERSION=$RABBITMQ_VERSION --file Dockerfile.windows --tag exivity/rabbitmq:$RABBITMQ_VERSION .
docker tag exivity/rabbitmq:$RABBITMQ_VERSION exivity/rabbitmq:latest
- name: test
run: ./rabbitmq/test.sh
- name: login
run: echo $DOCKER_HUB_TOKEN | docker login -u $DOCKER_HUB_USER --password-stdin
env:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: push
run: |
docker push exivity/rabbitmq:$RABBITMQ_VERSION
docker push exivity/rabbitmq:latest
31 changes: 3 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
# exivity/docker
# Exivity Docker images

Docker base images used at Exivity.

## tags

### :latest

Multiarch image containing both Windows and Linux images.

### :windows

_mcr.microsoft.com/windows/servercore:1903_

- PowerShell 6.2.0
- Node 10.15.3
- Visual C++ Redistributable for Visual Studio 2015
- Yarn 1.13.0
- Git for Windows 2.20.1

notes:
- previously, we used _mcr.microsoft.com/windows/nanoserver:1903_ but this turned out to be incompatible with nginx, see https://social.msdn.microsoft.com/Forums/en-US/7c30cb71-d449-4910-8bf5-f56023f7218e/nginx-in-nanoserver-container

### :linux

_ubuntu:latest_

- zip
- unzip
- [exivity/base](base/README.md)
- [exivity/rabbitmq](rabbitmq/README.md)
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# exivity/docker

Docker base images used at Exivity.

## tags

### :latest

Multiarch image containing both Windows and Linux images.

### :windows

_mcr.microsoft.com/windows/servercore:1903_

- PowerShell 6.2.0
- Node 10.15.3
- Visual C++ Redistributable for Visual Studio 2015
- Yarn 1.13.0
- Git for Windows 2.20.1

notes:
- previously, we used _mcr.microsoft.com/windows/nanoserver:1903_ but this turned out to be incompatible with nginx, see https://social.msdn.microsoft.com/Forums/en-US/7c30cb71-d449-4910-8bf5-f56023f7218e/nginx-in-nanoserver-container

### :linux

_ubuntu:latest_

- zip
- unzip
0 build.sh → base/build.sh
100755 → 100644
File renamed without changes.
0 manifest.sh → base/manifest.sh
100755 → 100644
File renamed without changes.
34 changes: 34 additions & 0 deletions rabbitmq/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2019

ARG VERSION

USER ContainerAdministrator

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV VERSION=$VERSION
ENV chocolateyUseWindowsCompression false
ENV ERLANG_SERVICE_MANAGER_PATH="C:\Program Files\erl10.7\erts-10.7\bin"
ENV RABBITMQ_SERVER="C:\Program Files\RabbitMQ Server\rabbitmq_server-${VERSION}"

RUN iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); \
choco install -y curl;
RUN choco install -y erlang --version 22.3
RUN curl ('https://github.com/rabbitmq/rabbitmq-server/releases/download/v{0}/rabbitmq-server-windows-{0}.zip' -f $env:VERSION) -o $env:TEMP\rabbitmq-server.zip; \
Expand-Archive "$env:TEMP\rabbitmq-server.zip" -DestinationPath 'C:\Program Files\RabbitMQ Server'; \
del "$env:TEMP\rabbitmq-server.zip";

COPY healthcheck.cmd C:/
COPY enabled_plugins C:/Users/ContainerAdministrator/AppData/Roaming/RabbitMQ/
COPY rabbitmq.conf C:/Users/ContainerAdministrator/AppData/Roaming/RabbitMQ/

EXPOSE 4369
EXPOSE 5671
EXPOSE 5672
EXPOSE 15672

HEALTHCHECK --interval=5s --timeout=60s CMD C:/healthcheck.cmd

WORKDIR C:/Program\ Files/RabbitMQ\ Server/rabbitmq_server-${VERSION}/sbin

CMD .\rabbitmq-server.bat
41 changes: 41 additions & 0 deletions rabbitmq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# exivity:rabbitmq

Builds Docker images of Rabbit MQ server, currently only on Windows.

## Commands during development

```
export $RABBITMQ_VERSION=3.8.6
```

Build:

```
docker build --build-arg VERSION=$RABBITMQ_VERSION --file Dockerfile.windows --tag exivity/rabbitmq:$RABBITMQ_VERSION .
```

Run interactively:

```
docker run --rm -it -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 --name rabbitmq exivity/rabbitmq:$RABBITMQ_VERSION
```

Run in background:

```
docker run --rm --detach -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 --name rabbitmq exivity/rabbitmq:$RABBITMQ_VERSION
```

Attach shell to running container:

```
docker exec -it rabbitmq cmd.exe
```

Then, i.e. follow log file:

```
powershell
Get-Content C:\Users\
ContainerAdministrator\AppData\Roaming\RabbitMQ\log\rabbit@HOSTNAME.log Wait
```
1 change: 1 addition & 0 deletions rabbitmq/enabled_plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[rabbitmq_amqp1_0,rabbitmq_management].
4 changes: 4 additions & 0 deletions rabbitmq/healthcheck.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REM curl --connect-timeout 5 --max-time 60 --retry 1 --user guest:guest http://localhost:15672/api/healthchecks/node

cd "C:/Program Files/RabbitMQ Server/rabbitmq_server-%VERSION%/sbin"
rabbitmqctl.bat ping
6 changes: 6 additions & 0 deletions rabbitmq/rabbitmq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# DANGER ZONE!
#
# allowing remote connections for default user is highly discouraged
# as it dramatically decreases the security of the system. Delete the user
# instead and create a new one with generated secure credentials.
loopback_users = none
52 changes: 52 additions & 0 deletions rabbitmq/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

healthy=healthy

# https://gist.github.com/sj26/88e1c6584397bb7c13bd11108a579746
function retry {
local retries=$1
shift

local count=0
until "$@"; do
exit=$?
wait=$((2 ** $count))
count=$(($count + 1))
if [ $count -lt $retries ]; then
echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
sleep $wait
else
echo "Retry $count/$retries exited $exit, no more retries left."
return $exit
fi
done
return 0
}

function health {
docker inspect --format='{{json .State.Health.Status}}' rabbitmq
}

function test {
status=`health`

echo "Got status $status"

[ $status = "\"$healthy\"" ]
}

set -e

docker run \
--rm \
--detach \
-p 4369:4369 \
-p 5671:5671 \
-p 5672:5672 \
-p 15672:15672 \
--name rabbitmq \
exivity/rabbitmq:latest

retry 10 test

docker stop rabbitmq

0 comments on commit d6c3a85

Please sign in to comment.