-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: push and pull from dockerhub
- Loading branch information
1 parent
3d8982c
commit dcedae0
Showing
4 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: CI/CD to staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up Docker environment | ||
run: | | ||
echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV | ||
echo "COMPOSE_DOCKER_CLI_BUILD=1" >> $GITHUB_ENV | ||
- name: Build and push with Docker Compose | ||
run: | | ||
docker compose -f docker-compose.yml build rest-api | ||
docker compose -f docker-compose.yml push rest-api | ||
CD: | ||
needs: CI | ||
runs-on: | ||
- self-hosted | ||
- staging | ||
|
||
steps: | ||
- name: Checkout the latest code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker Hub login | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Pull the Docker image | ||
run: | | ||
cd $GITHUB_WORKSPACE | ||
docker compose -f docker-compose.yml pull | ||
- name: Start the container | ||
run: | | ||
cd $GITHUB_WORKSPACE | ||
docker compose -f docker-compose.yml up -d | ||
- name: Remove old Docker images | ||
run: | | ||
docker rmi $(docker images devroadr/python-api-server -f "dangling=true" -q) || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
services: | ||
api: | ||
image: jorgeav527/api-rust | ||
rest-api: | ||
image: devroadr/cdci_rust | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
target: final | ||
ports: | ||
- "8000:8000" | ||
- "8080:8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters