Skip to content

Commit

Permalink
#18 portainer added as start admin stack
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Jun 2, 2021
1 parent 6eb6fde commit fe37e2c
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/deploy.admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Ansible workflow for single service deployment.
# Uses: https://github.com/dawidd6/action-ansible-playbook
# Options: https://github.com/dawidd6/action-ansible-playbook/blob/master/main.js
# Author: Just van den Broecke - 2021
#
name: admin Deploy ⚙️

# Trigger only when services/admin subdir changed
on:
push:
paths:
- 'services/admin/**'

jobs:
main:
runs-on: ubuntu-20.04

steps:
- name: Checkout ✅
uses: actions/checkout@v2

- name: Run playbook ⚙
uses: dawidd6/action-ansible-playbook@v2
with:
playbook: deploy.yml
directory: ./ansible
key: ${{secrets.ANSIBLE_SSH_PRIVATE_KEY}}
inventory: ${{secrets.ANSIBLE_INVENTORY_PROD}}
vault_password: ${{secrets.ANSIBLE_VAULT_PASSWORD}}
options: |
--tags admin
--verbose
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Traefik Deploy](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.traefik.yml/badge.svg)](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.traefik.yml)
[![pygeoapi Deploy](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.pygeoapi.yml/badge.svg)](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.pygeoapi.yml)
[![ldproxy Deploy](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.ldproxy.yml/badge.svg)](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.ldproxy.yml)
[![admin Deploy](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.admin.yml/badge.svg)](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.admin.yml)
[![docs Deploy](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.docs.yml/badge.svg)](https://github.com/Geonovum/ogc-api-testbed/actions/workflows/deploy.docs.yml)
[![Gitter](https://img.shields.io/gitter/room/Geonovum/ogc-api-testbed.svg?style=flat-square)](https://gitter.im/Geonovum/ogc-api-testbed)

Expand Down
4 changes: 4 additions & 0 deletions ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@
- name: "docs"
shell: "cd {{ services_home }}/docs && ./deploy.sh && docker ps"
tags: docs

- name: "admin"
shell: "cd {{ services_home }}/admin && ./deploy.sh && docker ps"
tags: docs
40 changes: 40 additions & 0 deletions services/admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Admin Stack

Runs various admin tools/services.

* Portainer (Community Edition)
* GeoHealthCheck (TODO)

## Deployment

This service is automatically (re)deployed if anything within this directory or its subdirs changes
when committed/pushed.

A GitHub Action invokes an Ansible Playbook.
See the following deployment files:

* [GitHub Action](../../.github/workflows/deploy.admin.yml)
* [Ansible Playbook](../../ansible/deploy.yml)

The Ansible Playbook can also be invoked directly.

## Specifics
### Portainer

* Image: https://hub.docker.com/r/portainer/portainer-ce/

**Admin Password**

Encrypted version, generated with Apache Utils

```
docker run --rm httpd:2.4-alpine htpasswd -nbB admin "THE PASSWORD" | cut -d ":" -f 2
```

Note escaped `$` in docker-compose.yml

```
- --admin-password=$$2y$$05$$VCjhk4z8mhi8V0DpXHX56.W1jy0sNWHOwSQbXVCYPyLs/WanBODPq
```
5 changes: 5 additions & 0 deletions services/admin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ../env.sh

./stop.sh && docker pull portainer/portainer-ce:latest && ./start.sh
53 changes: 53 additions & 0 deletions services/admin/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3.3'

services:

portainer:

image: portainer/portainer-ce:latest

container_name: portainer

expose:
- "9000"

ports:
- "9001:9000"

command:
- --admin-password=$$2y$$05$$VCjhk4z8mhi8V0DpXHX56.W1jy0sNWHOwSQbXVCYPyLs/WanBODPq

volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data

labels:
# Enable Traefik routing on overlay service network
- "traefik.enable=true"
- "traefik.docker.network=service-network"

- "traefik.http.middlewares.portainer-stripprefix.stripprefix.prefixes=/portainer"
- "traefik.http.services.frontend.loadbalancer.server.port=9000"

# SSL/https router
- "traefik.http.routers.portainer_https.rule=Host(`${TRAEFIK_SSL_DOMAIN}`) && PathPrefix(`/portainer`)"
- "traefik.http.routers.portainer_https.service=frontend"
- "traefik.http.routers.portainer_https.entrypoints=https"
- "traefik.http.routers.portainer_https.tls=${TRAEFIK_USE_TLS}"
- "traefik.http.routers.portainer_https.tls.certresolver=${TRAEFIK_SSL_CERT_RESOLVER}"
- "traefik.http.routers.portainer_https.tls.options=my_default@file"
- "traefik.http.routers.portainer_https.middlewares=portainer-stripprefix,secure-headers@file"

# local http router
- "traefik.http.routers.portainer_http.service=frontend"
- "traefik.http.routers.portainer_http.rule=Host(`localhost`) && PathPrefix(`/portainer`)"
- "traefik.http.routers.portainer_http.entrypoints=http"
- "traefik.http.routers.portainer_http.middlewares=portainer-stripprefix"

volumes:
portainer_data:

networks:
default:
external:
name: service-network
6 changes: 6 additions & 0 deletions services/admin/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

source ../env.sh

./stop.sh
docker-compose up -d
6 changes: 6 additions & 0 deletions services/admin/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

source ../env.sh

docker-compose stop
docker-compose rm --force

0 comments on commit fe37e2c

Please sign in to comment.