Skip to content

Commit 2d32111

Browse files
committed
Update README file to also include instructions about Docker image usage.
1 parent 67ddd9b commit 2d32111

File tree

1 file changed

+106
-49
lines changed

1 file changed

+106
-49
lines changed

README.md

Lines changed: 106 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,46 @@
55
</p>
66

77
<h1 align="center">
8-
Docker Stack Deploy Action
8+
Docker Stack Deploy Tool
99
</h1>
1010

11+
<div align="center">
12+
1113
[![GitHub Actions Marketplace](https://img.shields.io/badge/action-marketplace-blue.svg?logo=github&color=orange)](https://github.com/marketplace/actions/docker-stack-deploy-action)
1214
[![Release version badge](https://img.shields.io/github/v/release/kitconcept/docker-stack-deploy)](https://github.com/kitconcept/docker-stack-deploy/release)
15+
1316
![GitHub Repo stars](https://img.shields.io/github/stars/kitconcept/docker-stack-deploy?style=flat-square)
1417
[![license badge](https://img.shields.io/github/license/kitconcept/docker-stack-deploy)](./LICENSE)
1518

16-
GitHub Action and Docker image used to deploy a Docker stack on a Docker Swarm.
17-
18-
## Inputs
19-
20-
## `registry`
21-
22-
When using private images, specify which registry to login to. If no value is provided, we fallback to Docker Hub.
23-
24-
To use GitHub Container registry, set the value to **ghcr.io**.
25-
26-
## `username`
27-
28-
When using private images, specify username to be used to log in.
29-
30-
## `password`
31-
32-
When using private images, specify password to be used to log in.
33-
34-
## `remote_host`
35-
36-
**Required** Hostname or address of the machine running the Docker Swarm manager node.
37-
38-
## `remote_port`
39-
40-
SSH port to connect on the the machine running the Docker Swarm manager node.
41-
42-
**Default value**: 22
43-
44-
## `remote_user`
45-
46-
**Required** User with SSH and Docker privileges on the machine running the Docker Swarm manager node.
47-
48-
## `remote_private_key`
49-
50-
**Required** Private key used for ssh authentication.
19+
</div>
5120

52-
## `deploy_timeout`
53-
54-
Seconds, to wait until the deploy finishes.
21+
GitHub Action and Docker image used to deploy a Docker stack on a Docker Swarm.
5522

56-
**Default value**: 300
5723

58-
## `stack_file`
24+
## Configuration options
5925

60-
**Required** Path to the stack file used in the deploy.
26+
| GitHub Action Input | Environment Variable | Summary | Required | Default Value |
27+
| --- | --- | --- | --- | --- |
28+
| `registry` | `REGISTRY` | Specify which container registry to login to. | |
29+
| `username` | `USERNAME` | Container registry username. | | |
30+
| `password` | `PASSWORD` | Container registry password. | | |
31+
| `remote_host` | `REMOTE_HOST` | Hostname or address of the machine running the Docker Swarm manager node || |
32+
| `remote_port` | `REMOTE_PORT` | SSH port to connect on the the machine running the Docker Swarm manager node. | | **22** |
33+
| `remote_user` | `REMOTE_USER` | User with SSH and Docker privileges on the machine running the Docker Swarm manager node. || |
34+
| `remote_private_key` | `REMOTE_PRIVATE_KEY` | Private key used for ssh authentication. || |
35+
| `deploy_timeout` | `DEPLOY_TIMEOUT` | Seconds, to wait until the deploy finishes | | **600** |
36+
| `stack_file` | `STACK_FILE` | Path to the stack file used in the deploy. || |
37+
| `stack_name` | `STACK_NAME` | Name of the stack to be deployed. || |
38+
| `debug` | `DEBUG` | Verbose logging | | **0** |
6139

62-
## `stack_name`
6340

64-
**Required** Name of the stack to be deployed.
41+
## Using the GitHub Action
6542

43+
Add, or edit an existing, `yaml` file inside `.github/actions` and use the configuration options listed above.
6644

67-
## Examples
45+
### Examples
6846

69-
### Deploying public images
47+
#### Deploying public images
7048

7149

7250
```yaml
@@ -86,7 +64,7 @@ jobs:
8664
uses: actions/checkout@v2
8765

8866
- name: Deploy
89-
uses: kitconcept/[email protected].0
67+
uses: kitconcept/[email protected].1
9068
with:
9169
remote_host: ${{ secrets.REMOTE_HOST }}
9270
remote_user: ${{ secrets.REMOTE_USER }}
@@ -95,7 +73,7 @@ jobs:
9573
stack_name: "plone-staging"
9674
```
9775
98-
### Deploying private images from GitHub Container Registry
76+
#### Deploying private images from GitHub Container Registry
9977
10078
First, follow the steps to [create a Personal Access Token](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry).
10179
@@ -116,7 +94,7 @@ jobs:
11694
uses: actions/checkout@v2
11795

11896
- name: Deploy
119-
uses: kitconcept/[email protected].0
97+
uses: kitconcept/[email protected].1
12098
with:
12199
registry: "ghcr.io"
122100
username: ${{ secrets.GHCR_USERNAME }}
@@ -128,6 +106,85 @@ jobs:
128106
stack_name: "plone-live"
129107
```
130108
109+
## Using the Docker Image
110+
111+
It is possible to directly use the `ghcr.io/kitconcept/docker-stack-deploy` Docker image, passing the configuration options as environment variables.
112+
113+
### Examples
114+
115+
#### Local machine
116+
117+
Considering you have a local file named `.env_deploy` with content:
118+
119+
```
120+
REGISTRY=hub.docker.com
121+
USERNAME=foo_usr
122+
PASSWORD=averylargepasswordortoken
123+
REMOTE_HOST=192.168.17.2
124+
REMOTE_PORT=22
125+
REMOTE_USER=user
126+
STACK_FILE=path/to/stack.yml
127+
STACK_NAME=mystack
128+
DEBUG=1
129+
```
130+
131+
Run the following command:
132+
```shell
133+
docker run --rm
134+
-v "$(pwd)":/github/workspace
135+
-v /var/run/docker.sock:/var/run/docker.sock
136+
--env-file=.env_deploy
137+
-e REMOTE_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)"
138+
ghcr.io/kitconcept/docker-stack-deploy:latest
139+
```
140+
141+
#### GitLab CI
142+
143+
On your GitLab project, go to `Settings -> CI/CD` and add the environment variables under **Variables**.
144+
145+
Then edit your `.gitlab-cy.yml` to include the `deploy` step:
146+
147+
```yaml
148+
image: busybox:latest
149+
150+
services:
151+
- docker:20.10.16-dind
152+
153+
before_script:
154+
- docker info
155+
156+
deploy:
157+
stage: deploy
158+
varibles:
159+
REGISTRY: ${REGISTRY}
160+
USERNAME: ${REGISTRY_USER}
161+
PASSWORD: ${REGISTRY_PASSWORD}
162+
REMOTE_HOST: ${DEPLOY_HOST}
163+
REMOTE_PORT: 22
164+
REMOTE_USER: ${DEPLOY_USER}
165+
REMOTE_PRIVATE_KEY: "${DEPLOY_KEY}"
166+
STACK_FILE: stacks/app.yml
167+
STACK_NAME: app
168+
DEPLOY_IMAGE: ghcr.io/kitconcept/docker-stack-deploy:latest
169+
script:
170+
- docker pull ${DEPLOY_IMAGE}
171+
- docker run --rm
172+
-v "$(pwd)":/github/workspace
173+
-v /var/run/docker.sock:/var/run/docker.sock
174+
-e REGISTRY=${REGISTRY}
175+
-e USERNAME=${USERNAME}
176+
-e PASSWORD=${PASSWORD}
177+
-e REMOTE_HOST=${REMOTE_HOST}
178+
-e REMOTE_PORT=${REMOTE_PORT}
179+
-e REMOTE_USER=${REMOTE_USER}
180+
-e REMOTE_PRIVATE_KEY="${REMOTE_PRIVATE_KEY}"
181+
-e STACK_FILE=${STACK_FILE}
182+
-e STACK_NAME=${STACK_NAME}
183+
-e DEBUG=1
184+
${DEPLOY_IMAGE}
185+
186+
```
187+
131188
## Contribute
132189

133190
- [Issue Tracker](https://github.com/kitconcept/docker-stack-deploy/issues)

0 commit comments

Comments
 (0)