Skip to content

Commit

Permalink
feat(cd): publish and pull from dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jul 1, 2024
1 parent 66ec420 commit 5af9269
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 30 deletions.
75 changes: 70 additions & 5 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,73 @@ on:
- "LICENSE"

jobs:
dockerhub:
name: Publish Docker Image(s) to Dockerhub
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Cache Docker layers for MFTP Doctor
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-mftp-doctor
key: ${{ runner.os }}-buildx-mftp-doctor-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-mftp-doctor-
- name: Build & Push MFTP Doctor
uses: docker/build-push-action@v5
with:
context: ./mftp-doctor/
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/mftp-doctor:latest
cache-from: type=local,src=/tmp/.buildx-cache-mftp-doctor
cache-to: type=local,dest=/tmp/.buildx-cache-mftp-doctor-new,mode=max

- name: Move MFTP Doctor cache
run: |
rm -rf /tmp/.buildx-cache-mftp-doctor
mv /tmp/.buildx-cache-mftp-doctor-new /tmp/.buildx-cache-mftp-doctor
- name: Cache Docker layers for MFTP
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-mftp
key: ${{ runner.os }}-buildx-mftp-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-mftp-
- name: Build & Push MFTP
uses: docker/build-push-action@v5
with:
context: ./mftp/
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/mftp:latest
cache-from: type=local,src=/tmp/.buildx-cache-mftp
cache-to: type=local,dest=/tmp/.buildx-cache-mftp-new,mode=max

- name: Move MFTP cache
run: |
rm -rf /tmp/.buildx-cache-mftp
mv /tmp/.buildx-cache-mftp-new /tmp/.buildx-cache-mftp
push:
name: Push Stage
name: Push Code Stage
needs: dockerhub
runs-on: ubuntu-latest

steps:
Expand All @@ -30,13 +95,13 @@ jobs:
sudo git fetch origin
sudo git reset --hard origin/main
build:
name: Build Stage
pull:
name: Pull Image Stage
needs: push
runs-on: ubuntu-latest

steps:
- name: Build the latest container(s)
- name: Pull the latest images(s)
uses: appleboy/ssh-action@master
env:
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
Expand All @@ -49,4 +114,4 @@ jobs:
script_stop: true
script: |
cd "${PROJECT_DIR}/"
sudo docker compose --env-file .env build
sudo docker compose pull
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
build:
context: ./mftp
dockerfile: Dockerfile
image: proffapt/mftp
image: metakgporg/mftp
container_name: mftp
command: $MFTP_MODE
volumes:
Expand All @@ -22,7 +22,7 @@ services:
build:
context: ./mftp-doctor
dockerfile: Dockerfile
image: proffapt/mftp-doctor
image: metakgporg/mftp-doctor
container_name: mftp-doctor
command: ${DOCTOR_MODE:-}
volumes:
Expand Down
8 changes: 4 additions & 4 deletions mftp-doctor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following requirements are to be satisfied for the project to function prope
You can get the docker image from either docker-hub or by buiilding it locally:
- Pull from docker-hub
```sh
sudo docker pull proffapt/mftp-doctor
sudo docker pull metakgporg/mftp-doctor
```
- Build from Dockerfile
* Clone the repository and cd into it
Expand All @@ -56,7 +56,7 @@ The following requirements are to be satisfied for the project to function prope
```
* Build the image
```sh
sudo docker build -t proffapt/mftp-doctor .
sudo docker build -t metakgporg/mftp-doctor .
```
2. Create a directory which will contain your env.py, name it as `doctor_config`
3. Follow the steps to [configure env variables](#configuring-environment-variables)
Expand Down Expand Up @@ -87,7 +87,7 @@ This container requires access to hosts' `docker.sock` to check logs of `mftp` c
-v /var/run/docker.sock:/var/run/docker.sock \
-v /path/to/doctor_config/env.py:/mftp-doctor/env.py \
--name mftp-doctor \
proffapt/mftp-doctor
metakgporg/mftp-doctor
```
<p align="right">(<a href="#top">back to top</a>)</p>
Expand All @@ -107,7 +107,7 @@ It is also possible to run these docker containers as a cronjob:
-v /var/run/docker.sock:/var/run/docker.sock \
-v /path/to/doctor_config/env.py:/mftp-doctor/env.py \
--name mftp-doctor \
proffapt/mftp-doctor --cron
metakgporg/mftp-doctor --cron
```
- Add the updated command with desired [cron expression](https://crontab.cronhub.io/) into your cronjob using [crontab -e](https://www.man7.org/linux/man-pages/man5/crontab.5.html)
Expand Down
22 changes: 10 additions & 12 deletions mftp-doctor/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

version: "3"

services:

mftp-doctor:
build:
context: .
dockerfile: Dockerfile
image: proffapt/mftp-doctor
container_name: mftp-doctor
command: ${DOCTOR_MODE:-}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $DOCTOR_CONFIG/env.py:/mftp-doctor/env.py
mftp-doctor:
build:
context: .
dockerfile: Dockerfile
image: metakgporg/mftp-doctor
container_name: mftp-doctor
command: ${DOCTOR_MODE:-}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $DOCTOR_CONFIG/env.py:/mftp-doctor/env.py
12 changes: 6 additions & 6 deletions mftp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The following requirements are to be satisfied for the project to function prope
You can get the docker image from either docker-hub or by buiilding it locally:
- Pull from docker-hub
```sh
sudo docker pull proffapt/mftp
sudo docker pull metakgporg/mftp
```
- Build from Dockerfile
* Clone the repository and cd into it
Expand All @@ -57,7 +57,7 @@ The following requirements are to be satisfied for the project to function prope
```
* Build the image
```sh
sudo docker build -t proffapt/mftp .
sudo docker build -t metakgporg/mftp .
```
2. Create a directory which will contain your tokens and env.py, name it as `mftp_config`
3. Follow the steps to [configure mail sending](#sending-emails). **Skip this step if you wish to use method not involving mails, for example, ntfy**
Expand Down Expand Up @@ -104,7 +104,7 @@ It is mandatory to provide either of the following flags to the execution comman
-v /path/to/mftp_config/.session:/mftp/.session \
--restart=unless-stopped \
--name mftp \
proffapt/mftp --smtp
metakgporg/mftp --smtp
```

- `--gmail-api`: Using Gmail API for sending mails
Expand All @@ -119,7 +119,7 @@ It is mandatory to provide either of the following flags to the execution comman
-v /path/to/mftp_config/.session:/mftp/.session \
--restart=unless-stopped \
--name mftp \
proffapt/mftp --gmail-api
metakgporg/mftp --gmail-api
```

- `--ntfy`: Using NTFY to serve notification
Expand All @@ -134,7 +134,7 @@ It is mandatory to provide either of the following flags to the execution comman
-v /path/to/mftp_config/.session:/mftp/.session \
--restart=unless-stopped \
--name mftp \
proffapt/mftp --ntfy
metakgporg/mftp --ntfy
```

<p align="right">(<a href="#top">back to top</a>)</p>
Expand Down Expand Up @@ -169,7 +169,7 @@ It is also possible to run these docker containers as a cronjob:
-v /path/to/mftp_config/.lsnif:/mftp/.lsnif \
-v /path/to/mftp_config/.session:/mftp/.session \
--name mftp \
proffapt/mftp --gmail-api --cron
metakgporg/mftp --gmail-api --cron
```
- Add the updated command with desired [cron expression](https://crontab.cronhub.io/) into your cronjob using [crontab -e](https://www.man7.org/linux/man-pages/man5/crontab.5.html)

Expand Down
2 changes: 1 addition & 1 deletion mftp/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
build:
context: .
dockerfile: Dockerfile
image: proffapt/mftp
image: metakgporg/mftp
container_name: mftp
restart: unless-stopped
command: $MFTP_MODE
Expand Down

0 comments on commit 5af9269

Please sign in to comment.