mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Experimental support for Portainer CE 2.0 & 2.1
Added: - Test PSU with Portainer CE 2.0.1 API - Test PSU with Portainer CE 2.1.1 API Changed: - Use Docker Compose 1.28.3 instead of Docker Compose 1.26.2 - Use Traefik 2.4 instead of Traefik 2.2 for testing - Upgrade operating system of Docker based images, with Alpine 3.13 Removed: - Test PSU with Portainer 1.22.2 API - Test PSU with Portainer 1.23.2 API
This commit is contained in:
parent
498418f816
commit
5275fc78f2
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/tests/*-final.json
|
||||||
|
/tests/dockerfiles/.env
|
||||||
|
/tests/dockerfiles/*-final.yml
|
@ -3,8 +3,10 @@ image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/hub/auto-deploy-image:latest
|
|||||||
variables:
|
variables:
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
DOCKER_TLS_CERTDIR: "/certs"
|
DOCKER_TLS_CERTDIR: "/certs"
|
||||||
TRAEFIK_VERSION: "2.2"
|
TRAEFIK_VERSION: "2.4"
|
||||||
|
PORTAINER_IMAGE: "portainer/portainer-ce"
|
||||||
PORTAINER_VERSION: latest
|
PORTAINER_VERSION: latest
|
||||||
|
PORTAINER_COMMAND_OPTIONS: ""
|
||||||
PSU_IMAGE: ${CI_REGISTRY_IMAGE}/builds
|
PSU_IMAGE: ${CI_REGISTRY_IMAGE}/builds
|
||||||
PSU_TAG: $$CI_COMMIT_SHA
|
PSU_TAG: $$CI_COMMIT_SHA
|
||||||
PSU_TAG_CORE: core-$$CI_COMMIT_SHA
|
PSU_TAG_CORE: core-$$CI_COMMIT_SHA
|
||||||
@ -91,15 +93,18 @@ build:debian-core:
|
|||||||
- registry_login
|
- registry_login
|
||||||
- bash scripts/test.sh
|
- bash scripts/test.sh
|
||||||
|
|
||||||
test:portainer-1.22.2:
|
test:portainer-1.24.1:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
variables:
|
variables:
|
||||||
PORTAINER_VERSION: 1.22.2
|
PORTAINER_IMAGE: "portainer/portainer"
|
||||||
|
PORTAINER_VERSION: 1.24.1
|
||||||
|
PORTAINER_COMMAND_OPTIONS: " --no-analytics"
|
||||||
|
|
||||||
test:portainer-1.23.2:
|
|
||||||
|
test:portainer-2.0.1:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
variables:
|
variables:
|
||||||
PORTAINER_VERSION: 1.23.2
|
PORTAINER_VERSION: 2.0.1
|
||||||
|
|
||||||
test:portainer-latest:
|
test:portainer-latest:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
|
17
CHANGELOG.md
17
CHANGELOG.md
@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.2.0-alpha] - <abbr title="To Be Announced">TBA</abbr>
|
||||||
|
### Added
|
||||||
|
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.0.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) API
|
||||||
|
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.1.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) API
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Use Docker [Compose 1.28.3](https://github.com/docker/compose/releases/tag/1.28.3) instead of Docker [Compose 1.26.2](https://github.com/docker/compose/releases/tag/1.26.2)
|
||||||
|
- Use [Traefik 2.4](https://docs.traefik.io/traefik/) instead of [Traefik 2.2](https://docs.traefik.io/traefik/v2.2/) for testing
|
||||||
|
- Upgrade operating system of Docker based images, with [Alpine 3.13](https://hub.docker.com/_/alpine)
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.22.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.22.2) API
|
||||||
|
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.23.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.23.2) API
|
||||||
|
|
||||||
## [1.1.0] - 2021-02-18
|
## [1.1.0] - 2021-02-18
|
||||||
### Changed
|
### Changed
|
||||||
- Use [Traefik 2.2](https://docs.traefik.io/v2.2/) instead of [Traefik 2.1](https://docs.traefik.io/v2.1/) for testing
|
- Use [Traefik 2.2](https://docs.traefik.io/v2.2/) instead of [Traefik 2.1](https://docs.traefik.io/v2.1/) for testing
|
||||||
@ -106,7 +120,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Debug mode
|
- Debug mode
|
||||||
- Strict mode
|
- Strict mode
|
||||||
|
|
||||||
[Unreleased]: https://gitlab.com/psuapp/psu/compare/v1.1.0...1-1-stable
|
[Unreleased]: https://gitlab.com/psuapp/psu/compare/v1.2.0-alpha...1-2-next
|
||||||
|
[1.2.0-alpha]: https://gitlab.com/psuapp/psu/-/tags/v1.2.0-alpha
|
||||||
[1.1.0]: https://gitlab.com/psuapp/psu/-/tags/v1.1.0
|
[1.1.0]: https://gitlab.com/psuapp/psu/-/tags/v1.1.0
|
||||||
[1.1.0-alpha]: https://gitlab.com/psuapp/psu/-/tags/v1.1.0-alpha
|
[1.1.0-alpha]: https://gitlab.com/psuapp/psu/-/tags/v1.1.0-alpha
|
||||||
[1.0.7]: https://gitlab.com/psuapp/psu/-/tags/v1.0.7
|
[1.0.7]: https://gitlab.com/psuapp/psu/-/tags/v1.0.7
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
FROM alpine:3.12
|
FROM alpine:3.13
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
bash ca-certificates gettext jq \
|
bash ca-certificates gettext jq \
|
||||||
py3-pip python3-dev libc-dev libffi-dev openssl-dev gcc make musl-dev cargo; \
|
py3-pip python3-dev libc-dev libffi-dev openssl-dev gcc make musl-dev cargo; \
|
||||||
\
|
\
|
||||||
pip3 --no-cache-dir install 'docker-compose>=1.26.2,<1.27.0' 'httpie>=1.0.3,<1.1.0' 'cryptography>=3.3.0,<3.4.0'; \
|
pip3 --no-cache-dir install 'docker-compose>=1.28.3,<1.29.0' 'httpie>=1.0.3,<1.1.0' 'cryptography>=3.3.2,<3.4.0'; \
|
||||||
\
|
\
|
||||||
apk del python3-dev libc-dev libffi-dev openssl-dev gcc make musl-dev cargo; \
|
apk del python3-dev libc-dev libffi-dev openssl-dev gcc make musl-dev cargo; \
|
||||||
rm -rf /tmp/src
|
rm -rf /tmp/src
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM alpine:3.12
|
FROM alpine:3.13
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
|
@ -5,7 +5,7 @@ RUN set -e; \
|
|||||||
apt-get install \
|
apt-get install \
|
||||||
ca-certificates gettext-base httpie jq curl -yqq; \
|
ca-certificates gettext-base httpie jq curl -yqq; \
|
||||||
\
|
\
|
||||||
curl -fL "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose; \
|
curl -fL "https://github.com/docker/compose/releases/download/1.28.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose; \
|
||||||
chmod +x /usr/local/bin/docker-compose; \
|
chmod +x /usr/local/bin/docker-compose; \
|
||||||
\
|
\
|
||||||
apt-get purge curl -y; \
|
apt-get purge curl -y; \
|
||||||
|
19
README.md
19
README.md
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
[![Docker Pulls](https://img.shields.io/docker/pulls/psuapp/psu.svg)](https://hub.docker.com/r/psuapp/psu/)
|
[![Docker Pulls](https://img.shields.io/docker/pulls/psuapp/psu.svg)](https://hub.docker.com/r/psuapp/psu/)
|
||||||
[![Microbadger](https://images.microbadger.com/badges/image/psuapp/psu.svg)](http://microbadger.com/images/psuapp/psu "Image size")
|
[![Microbadger](https://images.microbadger.com/badges/image/psuapp/psu.svg)](http://microbadger.com/images/psuapp/psu "Image size")
|
||||||
[![pipeline status](https://gitlab.com/psuapp/psu/badges/1-1-stable/pipeline.svg)](https://gitlab.com/psuapp/psu/commits/1-1-stable)
|
[![pipeline status](https://gitlab.com/psuapp/psu/badges/1-2-next/pipeline.svg)](https://gitlab.com/psuapp/psu/commits/1-2-next)
|
||||||
|
|
||||||
Bash script to deploy/update/remove stacks in a [Portainer](https://portainer.io/) instance from a [docker-compose](https://docs.docker.com/compose) [yaml file](https://docs.docker.com/compose/compose-file).
|
Bash script to deploy/update/remove stacks in a [Portainer](https://portainer.io/) instance from a [docker-compose](https://docs.docker.com/compose) [yaml file](https://docs.docker.com/compose/compose-file).
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ For Debian and similar apt-powered systems: `apt install bash httpie jq`.
|
|||||||
|
|
||||||
If you don't want or can't install `psu` and its dependencies, you can run it with the default [published Docker image](https://hub.docker.com/r/psuapp/psu), like this:
|
If you don't want or can't install `psu` and its dependencies, you can run it with the default [published Docker image](https://hub.docker.com/r/psuapp/psu), like this:
|
||||||
```bash
|
```bash
|
||||||
docker run psuapp/psu:1.1 deploy ...
|
docker run psuapp/psu:1.2 deploy ...
|
||||||
```
|
```
|
||||||
> **Note**: Docker images are also available on [GitLab](https://gitlab.com/psuapp/psu/container_registry).
|
> **Note**: Docker images are also available on [GitLab](https://gitlab.com/psuapp/psu/container_registry).
|
||||||
|
|
||||||
@ -66,6 +66,7 @@ For detailed instructions, see [How to use](#how-to-use) section.
|
|||||||
Published Docker images are [tagged](https://hub.docker.com/r/psuapp/psu/tags) matching [GitLab tags](https://gitlab.com/psuapp/psu/-/tags):
|
Published Docker images are [tagged](https://hub.docker.com/r/psuapp/psu/tags) matching [GitLab tags](https://gitlab.com/psuapp/psu/-/tags):
|
||||||
|
|
||||||
<!-- - `dev` -> [`dev`](https://gitlab.com/psuapp/psu/-/tags/dev) -->
|
<!-- - `dev` -> [`dev`](https://gitlab.com/psuapp/psu/-/tags/dev) -->
|
||||||
|
- `1.2.0-alpha` -> [`v1.2.0-alpha`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0-alpha)
|
||||||
- `1`, `1.1`, `1.1.0` -> [`v1.1.0`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0)
|
- `1`, `1.1`, `1.1.0` -> [`v1.1.0`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0)
|
||||||
- `1.1.0-alpha` -> [`v1.1.0-alpha`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0-alpha)
|
- `1.1.0-alpha` -> [`v1.1.0-alpha`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0-alpha)
|
||||||
- `1.0`, `1.0.7` -> [`v1.0.7`](https://gitlab.com/psuapp/psu/-/tags/v1.0.7)
|
- `1.0`, `1.0.7` -> [`v1.0.7`](https://gitlab.com/psuapp/psu/-/tags/v1.0.7)
|
||||||
@ -101,10 +102,10 @@ The `debian` and `debian-core` variants use [Debian](https://www.debian.org) ins
|
|||||||
|
|
||||||
For testing/debugging, you can use this Docker image in interactive mode, to run any commands inside the container:
|
For testing/debugging, you can use this Docker image in interactive mode, to run any commands inside the container:
|
||||||
```bash
|
```bash
|
||||||
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -it --rm --entrypoint bash psuapp/psu:1.1
|
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -it --rm --entrypoint bash psuapp/psu:1.2
|
||||||
# Run any commands here! E.g.
|
# Run any commands here! E.g.
|
||||||
$ psu --version
|
$ psu --version
|
||||||
Portainer Stack Utils, version 1.1.0
|
Portainer Stack Utils, version 1.2.0-alpha
|
||||||
License GPLv3: GNU GPL version 3
|
License GPLv3: GNU GPL version 3
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ bash ./psu rm --user admin --password password --url https://portainer.local --n
|
|||||||
|
|
||||||
**With Docker:**
|
**With Docker:**
|
||||||
```bash
|
```bash
|
||||||
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.1 deploy --user admin --password password --url https://portainer.local --name mystack --compose-file docker-compose.yml --env-file .env
|
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.2 deploy --user admin --password password --url https://portainer.local --name mystack --compose-file docker-compose.yml --env-file .env
|
||||||
```
|
```
|
||||||
|
|
||||||
### With flags
|
### With flags
|
||||||
@ -165,7 +166,7 @@ bash ./psu rm -u admin -p password -l https://portainer.local -n mystack
|
|||||||
|
|
||||||
**With Docker:**
|
**With Docker:**
|
||||||
```bash
|
```bash
|
||||||
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.1 deploy -u admin -p password -l https://portainer.local -n mystack -c docker-compose.yml -g .env
|
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.2 deploy -u admin -p password -l https://portainer.local -n mystack -c docker-compose.yml -g .env
|
||||||
```
|
```
|
||||||
|
|
||||||
### With envvars
|
### With envvars
|
||||||
@ -207,20 +208,20 @@ bash ./psu
|
|||||||
|
|
||||||
**With Docker:**
|
**With Docker:**
|
||||||
```bash
|
```bash
|
||||||
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env -e ACTION="deploy" -e PORTAINER_USER="admin" -e PORTAINER_PASSWORD="password" -e PORTAINER_URL="https://portainer.local" -e PORTAINER_STACK_NAME="mystack" -e DOCKER_COMPOSE_FILE="docker-compose.yml" -e ENVIRONMENT_VARIABLES_FILE=".env" psuapp/psu:1.1
|
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env -e ACTION="deploy" -e PORTAINER_USER="admin" -e PORTAINER_PASSWORD="password" -e PORTAINER_URL="https://portainer.local" -e PORTAINER_STACK_NAME="mystack" -e DOCKER_COMPOSE_FILE="docker-compose.yml" -e ENVIRONMENT_VARIABLES_FILE=".env" psuapp/psu:1.2
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
<div class="docsify-hidden">
|
<div class="docsify-hidden">
|
||||||
For advanced usage, see the full <a href="https://psuapp.gitlab.io/psu/1-1-stable"><abbr title="Portainer Stack Utils">PSU</abbr> documentation</a>.
|
For advanced usage, see the full <a href="https://psuapp.gitlab.io/psu/1-2-next"><abbr title="Portainer Stack Utils">PSU</abbr> documentation</a>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
For detailed instructions, see the [CLI Commands](docs/README.md) documentation.
|
For detailed instructions, see the [CLI Commands](docs/README.md) documentation.
|
||||||
|
|
||||||
## Supported Portainer API
|
## Supported Portainer API
|
||||||
|
|
||||||
<abbr title="Portainer Stack Utils">PSU</abbr> was created for the latest versions of Portainer API, which at the time of writing are [1.22.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.22.2), [1.23.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.23.2) and [1.24.1](https://app.swaggerhub.com/apis/deviantony/Portainer/1.24.1).
|
<abbr title="Portainer Stack Utils">PSU</abbr> was created for the latest versions of Portainer API, which at the time of writing are [1.24.1](https://app.swaggerhub.com/apis/deviantony/Portainer/1.24.1), [2.0.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) and [2.1.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
2
psu
2
psu
@ -27,7 +27,7 @@ set -e
|
|||||||
# None #
|
# None #
|
||||||
############################
|
############################
|
||||||
main() {
|
main() {
|
||||||
VERSION="1.1.0"
|
VERSION="1.2.0-alpha"
|
||||||
|
|
||||||
OPTIONS_TABLE=(
|
OPTIONS_TABLE=(
|
||||||
# option_key;flag_text;option_text;description
|
# option_key;flag_text;option_text;description
|
||||||
|
27
tests/dockerfiles/.env.local
Normal file
27
tests/dockerfiles/.env.local
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#TRACE=true
|
||||||
|
|
||||||
|
CI_REGISTRY=localhost.com
|
||||||
|
CI_PROJECT_NAMESPACE=psuapp
|
||||||
|
CI_REGISTRY_IMAGE=localhost.com/psupapp/psu
|
||||||
|
CI_REGISTRY_USER=gitlab-ci-token
|
||||||
|
CI_REGISTRY_PASSWORD=longalfanumstring
|
||||||
|
CI_COMMIT_SHA=ee7ee6556462d46423840dcc49991be630545f60
|
||||||
|
#DOCKER_REGISTRY_IMAGE=$DOCKER_REGISTRY/$CI_PROJECT_PATH
|
||||||
|
|
||||||
|
PSU_IMAGE=localhost.com/psuapp/psu/builds
|
||||||
|
PSU_TAG=ee7ee6556462d46423840dcc49991be630545f60
|
||||||
|
PSU_TAG_CORE=core-ee7ee6556462d46423840dcc49991be630545f60
|
||||||
|
PSU_PASSWORD=portainerAdminPassword
|
||||||
|
|
||||||
|
TRAEFIK_VERSION="2.4"
|
||||||
|
|
||||||
|
PORTAINER_IMAGE="portainer/portainer-ce"
|
||||||
|
#PORTAINER_IMAGE="portainer/portainer"
|
||||||
|
PORTAINER_VERSION=latest
|
||||||
|
#PORTAINER_VERSION="2.0.1"
|
||||||
|
#PORTAINER_VERSION="1.24.1"
|
||||||
|
PORTAINER_COMMAND_OPTIONS=""
|
||||||
|
#PORTAINER_COMMAND_OPTIONS=" --no-analytics"
|
||||||
|
|
||||||
|
CLUSTER_NAME=localhost
|
||||||
|
CLUSTER_IP=$(hostname -I | awk '{ print $1 }')
|
@ -1,12 +1,12 @@
|
|||||||
version: '3.6'
|
version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
portainer:
|
portainer:
|
||||||
image: portainer/portainer:$PORTAINER_VERSION
|
image: ${PORTAINER_IMAGE}:${PORTAINER_VERSION}
|
||||||
command: --admin-password-file '/run/secrets/portainer-password' --no-analytics
|
command: --admin-password-file '/run/secrets/psu-portainer-password'${PORTAINER_COMMAND_OPTIONS}
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.docker.network=traefik-net
|
- traefik.docker.network=psu-traefik-net
|
||||||
# HTTPS route
|
# HTTPS route
|
||||||
- "traefik.http.routers.portainer.entrypoints=https"
|
- "traefik.http.routers.portainer.entrypoints=https"
|
||||||
- "traefik.http.routers.portainer.rule=Host(`portainer.$BASE_DOMAIN`)"
|
- "traefik.http.routers.portainer.rule=Host(`portainer.$BASE_DOMAIN`)"
|
||||||
@ -18,7 +18,7 @@ services:
|
|||||||
# Service
|
# Service
|
||||||
- traefik.http.services.portainer.loadbalancer.server.port=9000
|
- traefik.http.services.portainer.loadbalancer.server.port=9000
|
||||||
networks:
|
networks:
|
||||||
- traefik-net
|
- psu-traefik-net
|
||||||
environment:
|
environment:
|
||||||
- HTTP_PROXY
|
- HTTP_PROXY
|
||||||
- HTTPS_PROXY
|
- HTTPS_PROXY
|
||||||
@ -27,9 +27,9 @@ services:
|
|||||||
- NO_PROXY
|
- NO_PROXY
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- portainer:/data
|
- psu-portainer:/data
|
||||||
secrets:
|
secrets:
|
||||||
- portainer-password
|
- psu-portainer-password
|
||||||
deploy:
|
deploy:
|
||||||
placement:
|
placement:
|
||||||
constraints:
|
constraints:
|
||||||
@ -39,12 +39,12 @@ services:
|
|||||||
delay: 10s
|
delay: 10s
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
traefik-net:
|
psu-traefik-net:
|
||||||
driver: overlay
|
driver: overlay
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
portainer-password:
|
psu-portainer-password:
|
||||||
external: true
|
external: true
|
||||||
volumes:
|
volumes:
|
||||||
portainer:
|
psu-portainer:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: '3.6'
|
version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
reverse-proxy:
|
reverse-proxy:
|
||||||
@ -19,7 +19,7 @@ services:
|
|||||||
- NO_PROXY
|
- NO_PROXY
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- traefik.docker.network=traefik-net
|
- traefik.docker.network=psu-traefik-net
|
||||||
- traefik.http.middlewares.retry-if-fails.retry.attempts=10
|
- traefik.http.middlewares.retry-if-fails.retry.attempts=10
|
||||||
- traefik.http.middlewares.https-only.redirectscheme.scheme=https
|
- traefik.http.middlewares.https-only.redirectscheme.scheme=https
|
||||||
- traefik.http.middlewares.secured.chain.middlewares=retry-if-fails,https-only
|
- traefik.http.middlewares.secured.chain.middlewares=retry-if-fails,https-only
|
||||||
@ -32,7 +32,7 @@ services:
|
|||||||
- "80:80"
|
- "80:80"
|
||||||
- 443:443
|
- 443:443
|
||||||
networks:
|
networks:
|
||||||
- traefik-net
|
- psu-traefik-net
|
||||||
volumes:
|
volumes:
|
||||||
# So that Traefik can listen to the Docker events
|
# So that Traefik can listen to the Docker events
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
@ -46,6 +46,6 @@ services:
|
|||||||
delay: 10s
|
delay: 10s
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
traefik-net:
|
psu-traefik-net:
|
||||||
driver: overlay
|
driver: overlay
|
||||||
name: traefik-net
|
name: psu-traefik-net
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: '3.6'
|
version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
job:
|
job:
|
||||||
@ -27,7 +27,7 @@ services:
|
|||||||
- https_proxy
|
- https_proxy
|
||||||
- NO_PROXY
|
- NO_PROXY
|
||||||
volumes:
|
volumes:
|
||||||
- php-runner:/var/run/php
|
- psu-php-runner:/var/run/php
|
||||||
deploy:
|
deploy:
|
||||||
update_config:
|
update_config:
|
||||||
order: start-first
|
order: start-first
|
||||||
@ -37,7 +37,7 @@ services:
|
|||||||
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/hub/testing/psu-apache2:latest
|
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/hub/testing/psu-apache2:latest
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.docker.network=traefik-net
|
- traefik.docker.network=psu-traefik-net
|
||||||
# HTTPS route
|
# HTTPS route
|
||||||
- "traefik.http.routers.web-php-app.entrypoints=https"
|
- "traefik.http.routers.web-php-app.entrypoints=https"
|
||||||
- "traefik.http.routers.web-php-app.rule=Host(`$PSU_STACK_NAME.$BASE_DOMAIN`)"
|
- "traefik.http.routers.web-php-app.rule=Host(`$PSU_STACK_NAME.$BASE_DOMAIN`)"
|
||||||
@ -56,17 +56,17 @@ services:
|
|||||||
- https_proxy
|
- https_proxy
|
||||||
- NO_PROXY
|
- NO_PROXY
|
||||||
volumes:
|
volumes:
|
||||||
- php-runner:/var/run/php
|
- psu-php-runner:/var/run/php
|
||||||
deploy:
|
deploy:
|
||||||
update_config:
|
update_config:
|
||||||
failure_action: rollback
|
failure_action: rollback
|
||||||
order: start-first
|
order: start-first
|
||||||
networks:
|
networks:
|
||||||
- traefik-net
|
- psu-traefik-net
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
traefik-net:
|
psu-traefik-net:
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
php-runner:
|
psu-php-runner:
|
||||||
|
53
tests/run.sh
53
tests/run.sh
@ -1,13 +1,25 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Change working directory to 'tests/'
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
# Using .env file when running tests without GitLab CI
|
||||||
|
if [[ -f "dockerfiles/.env" ]]; then
|
||||||
|
set -a
|
||||||
|
source "dockerfiles/.env"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
[[ "$TRACE" ]] && set -x
|
[[ "$TRACE" ]] && set -x
|
||||||
|
|
||||||
CLUSTER_IP=$(getent hosts cluster | awk '{ print $1 }')
|
CLUSTER_NAME=${CLUSTER_NAME:-cluster}
|
||||||
|
CLUSTER_IP=${CLUSTER_IP:-$(getent hosts $CLUSTER_NAME | awk '{ print $1 }')}
|
||||||
export BASE_DOMAIN="$CLUSTER_IP.nip.io"
|
export BASE_DOMAIN="$CLUSTER_IP.nip.io"
|
||||||
export PSU_STACK_NAME="web-app"
|
export PSU_STACK_NAME="web-app"
|
||||||
PSU_URL="https://portainer.$BASE_DOMAIN"
|
PSU_URL="https://portainer.$BASE_DOMAIN"
|
||||||
PSU_USER="admin"
|
PSU_USER="admin"
|
||||||
PSU_PASSWORD="mypassword"
|
PSU_PASSWORD=${PSU_PASSWORD:-"$(openssl rand -hex 50)"}
|
||||||
|
|
||||||
PSU_TAG=$(if [ -n "$PSU_TAG" ]; then
|
PSU_TAG=$(if [ -n "$PSU_TAG" ]; then
|
||||||
eval echo "$PSU_TAG";
|
eval echo "$PSU_TAG";
|
||||||
@ -23,9 +35,6 @@ PSU_TAG_CORE=$(if [ -n "$PSU_TAG_CORE" ]; then
|
|||||||
fi)
|
fi)
|
||||||
export PSU_TAG_CORE
|
export PSU_TAG_CORE
|
||||||
|
|
||||||
# Change working directory to 'tests/'
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
function psu_wrapper() {
|
function psu_wrapper() {
|
||||||
docker run --rm $PSU_IMAGE:$PSU_TAG "$@"
|
docker run --rm $PSU_IMAGE:$PSU_TAG "$@"
|
||||||
}
|
}
|
||||||
@ -53,6 +62,23 @@ function application_exists() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Source: https://stackoverflow.com/a/24067243
|
||||||
|
function version {
|
||||||
|
echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Leave Docker Swarm, if already set
|
||||||
|
docker swarm leave --force && sleep 3 | true
|
||||||
|
|
||||||
|
# Remove admin password from Docker secrets, if already set
|
||||||
|
docker secret rm psu-portainer-password | true
|
||||||
|
|
||||||
|
# Remove portainer data, if already set
|
||||||
|
docker volume rm --force portainer_psu-portainer && sleep 2 | true
|
||||||
|
|
||||||
|
# Remove web-app data, if already set
|
||||||
|
docker volume rm --force web-app_psu-php-runner && sleep 2 | true
|
||||||
|
|
||||||
# Init Docker Swarm
|
# Init Docker Swarm
|
||||||
docker swarm init
|
docker swarm init
|
||||||
|
|
||||||
@ -60,12 +86,15 @@ docker swarm init
|
|||||||
# Parse the Docker traefik stack file to deploy
|
# Parse the Docker traefik stack file to deploy
|
||||||
envsubst '$TRAEFIK_VERSION,$BASE_DOMAIN' < dockerfiles/docker-stack-traefik.yml > dockerfiles/docker-stack-traefik-final.yml
|
envsubst '$TRAEFIK_VERSION,$BASE_DOMAIN' < dockerfiles/docker-stack-traefik.yml > dockerfiles/docker-stack-traefik-final.yml
|
||||||
docker stack deploy -c dockerfiles/docker-stack-traefik-final.yml traefik --with-registry-auth
|
docker stack deploy -c dockerfiles/docker-stack-traefik-final.yml traefik --with-registry-auth
|
||||||
bash -c "timeout 20 bash -c 'while ! (echo > /dev/tcp/cluster/443 && curl -fks --max-time 2 https://traefik.$BASE_DOMAIN) >/dev/null 2>&1; do sleep 1; done;'"
|
bash -c "timeout 20 bash -c 'while ! (echo > /dev/tcp/$CLUSTER_NAME/443 && curl -fks --max-time 2 https://traefik.$BASE_DOMAIN) >/dev/null 2>&1; do sleep 1; done;'"
|
||||||
|
|
||||||
# Deploy Portainer test
|
# Deploy Portainer test
|
||||||
echo -n $PSU_PASSWORD | docker secret create portainer-password -
|
# Create admin password as a Docker secret
|
||||||
|
# See: https://documentation.portainer.io/v2.0/deploy/initial/
|
||||||
|
echo -n $PSU_PASSWORD | docker secret create psu-portainer-password -
|
||||||
|
|
||||||
# Parse the Docker portainer stack file to deploy
|
# Parse the Docker portainer stack file to deploy
|
||||||
envsubst '$PORTAINER_VERSION,$BASE_DOMAIN' < dockerfiles/docker-stack-portainer.yml > dockerfiles/docker-stack-portainer-final.yml
|
envsubst '$PORTAINER_IMAGE,$PORTAINER_VERSION,$PORTAINER_COMMAND_OPTIONS,$BASE_DOMAIN' < dockerfiles/docker-stack-portainer.yml > dockerfiles/docker-stack-portainer-final.yml
|
||||||
docker stack deploy -c dockerfiles/docker-stack-portainer-final.yml portainer --with-registry-auth
|
docker stack deploy -c dockerfiles/docker-stack-portainer-final.yml portainer --with-registry-auth
|
||||||
bash -c "timeout 20 bash -c 'while ! (curl -fkLs --max-time 2 $PSU_URL) >/dev/null 2>&1; do sleep 1; done;'"
|
bash -c "timeout 20 bash -c 'while ! (curl -fkLs --max-time 2 $PSU_URL) >/dev/null 2>&1; do sleep 1; done;'"
|
||||||
|
|
||||||
@ -86,8 +115,14 @@ PSU_AUTH_TOKEN=$(psu_wrapper login --user $PSU_USER --password $PSU_PASSWORD --u
|
|||||||
# Add GitLab Docker registry access to Portainer
|
# Add GitLab Docker registry access to Portainer
|
||||||
envsubst '$CI_REGISTRY_USER,$CI_REGISTRY_PASSWORD' < gitlab-registry.json > gitlab-registry-final.json
|
envsubst '$CI_REGISTRY_USER,$CI_REGISTRY_PASSWORD' < gitlab-registry.json > gitlab-registry-final.json
|
||||||
http --check-status --ignore-stdin --verify=no --timeout=10 POST "$PSU_URL/api/registries" "Authorization: Bearer $PSU_AUTH_TOKEN" @gitlab-registry-final.json
|
http --check-status --ignore-stdin --verify=no --timeout=10 POST "$PSU_URL/api/registries" "Authorization: Bearer $PSU_AUTH_TOKEN" @gitlab-registry-final.json
|
||||||
|
|
||||||
# Add local endpoint to the Portainer instance
|
# Add local endpoint to the Portainer instance
|
||||||
http --check-status --ignore-stdin --verify=no --timeout=10 POST "$PSU_URL/api/endpoints" "Authorization: Bearer $PSU_AUTH_TOKEN" Name==local EndpointType==1
|
end_point_type_param=EndpointType
|
||||||
|
if [[ "$PORTAINER_VERSION" == "latest" ]] || [ "$(version $PORTAINER_VERSION)" -ge "$(version 2.0)" ]; then
|
||||||
|
# See: https://github.com/portainer/portainer/issues/4602#issuecomment-746819197
|
||||||
|
end_point_type_param=EndpointCreationType
|
||||||
|
fi
|
||||||
|
http --check-status --ignore-stdin --verify=no --timeout=10 POST "$PSU_URL/api/endpoints" "Authorization: Bearer $PSU_AUTH_TOKEN" Name==local $end_point_type_param==1
|
||||||
|
|
||||||
# Docker system info from Portainer test
|
# Docker system info from Portainer test
|
||||||
docker_info=$(psu_wrapper system:info --user $PSU_USER --password $PSU_PASSWORD --url $PSU_URL --insecure --debug false --verbose false)
|
docker_info=$(psu_wrapper system:info --user $PSU_USER --password $PSU_PASSWORD --url $PSU_URL --insecure --debug false --verbose false)
|
||||||
|
Loading…
Reference in New Issue
Block a user