Compare commits
26 Commits
fd28eccdf4
...
f1384a8197
| Author | SHA1 | Date | |
|---|---|---|---|
| f1384a8197 | |||
| bfa8d525a2 | |||
| c8a92f7ded | |||
| 628f5ddda4 | |||
| 80af066775 | |||
| fbaf97cc65 | |||
| ea73b4208a | |||
| 4eef154b65 | |||
| 3360016a31 | |||
| ff6ec619c5 | |||
| a07e8a8578 | |||
| 634d3ac389 | |||
| 0d20520c07 | |||
| 97a0354be5 | |||
| 39f37a2c4e | |||
| f7a69335d0 | |||
| 485b6e2122 | |||
| e622e01b46 | |||
| 8cc7e7c61b | |||
| 4a27c2445c | |||
| 4631f2dc44 | |||
| c4eef0ff42 | |||
| c93b64631c | |||
| adfa1b582a | |||
| 8291554a9e | |||
| 9a8757580c |
@@ -15,6 +15,8 @@ env:
|
|||||||
# Set the absolute path for your production deployment on the remote server.
|
# Set the absolute path for your production deployment on the remote server.
|
||||||
REMOTE_PROD_PATH: /var/app/traefik/prod
|
REMOTE_PROD_PATH: /var/app/traefik/prod
|
||||||
|
|
||||||
|
REMOTE_STAGING_PATH: /var/app/traefik/staging
|
||||||
|
|
||||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||||
SSH_USER: ${{ secrets.SSH_USER }}
|
SSH_USER: ${{ secrets.SSH_USER }}
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
@@ -90,13 +92,23 @@ jobs:
|
|||||||
source: "./"
|
source: "./"
|
||||||
target: "${{ needs.prepare_deployment_vars.outputs.deploy_path }}"
|
target: "${{ needs.prepare_deployment_vars.outputs.deploy_path }}"
|
||||||
|
|
||||||
run_docker_compose:
|
- name: Sync file via scp (staging)
|
||||||
name: Run docker-compose remotely
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: appleboy/scp-action@master
|
||||||
|
with:
|
||||||
|
host: ${{ env.SSH_HOST }}
|
||||||
|
username: ${{ env.SSH_USER }}
|
||||||
|
key: ${{ env.SSH_PRIVATE_KEY }}
|
||||||
|
port: ${{ env.SSH_PORT }}
|
||||||
|
source: "./"
|
||||||
|
target: ${{ env.REMOTE_STAGING_PATH }}
|
||||||
|
|
||||||
|
run_docker_compose_dev:
|
||||||
|
name: Run docker-compose remotely (Dev)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [sync_repo_files, prepare_deployment_vars]
|
needs: [sync_repo_files, prepare_deployment_vars]
|
||||||
if: |
|
if: |
|
||||||
(github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.merged == false)
|
(github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.merged == false)
|
||||||
|| github.ref == 'refs/heads/main'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup SSH
|
- name: Setup SSH
|
||||||
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1
|
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1
|
||||||
@@ -114,7 +126,57 @@ jobs:
|
|||||||
chmod 644 ~/.ssh/known_hosts
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
|
||||||
- name: Run docker-compose on remote host
|
- name: Run docker-compose on remote host
|
||||||
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd '${{ needs.prepare_deployment_vars.outputs.deploy_path }}' && docker-compose up -d --build"
|
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd '${{ needs.prepare_deployment_vars.outputs.deploy_path }}' && docker-compose --env-file dev.env -f docker-compose.yaml up -d --build"
|
||||||
|
|
||||||
|
run_docker_compose_staging:
|
||||||
|
name: Run docker-compose remotely (Staging)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [sync_repo_files, prepare_deployment_vars]
|
||||||
|
if: |
|
||||||
|
(github.ref == 'refs/heads/main')
|
||||||
|
steps:
|
||||||
|
- name: Setup SSH
|
||||||
|
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Add host to known_hosts
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
ssh-keyscan -p "$SSH_PORT" -T 10 -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||||
|
echo "::error::Failed to ssh-keyscan $SSH_HOST:$SSH_PORT"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Run docker-compose on remote host
|
||||||
|
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd '${REMOTE_STAGING_PATH}' && docker-compose --env-file staging.env -f docker-compose.yaml up -d --build"
|
||||||
|
|
||||||
|
run_docker_compose_prod:
|
||||||
|
name: Run docker-compose remotely (Prod)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [sync_repo_files, prepare_deployment_vars]
|
||||||
|
if: |
|
||||||
|
(github.ref == 'refs/heads/main')
|
||||||
|
steps:
|
||||||
|
- name: Setup SSH
|
||||||
|
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Add host to known_hosts
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
ssh-keyscan -p "$SSH_PORT" -T 10 -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||||
|
echo "::error::Failed to ssh-keyscan $SSH_HOST:$SSH_PORT"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Run docker-compose on remote host
|
||||||
|
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd '${{ needs.prepare_deployment_vars.outputs.deploy_path }}' && docker-compose --env-file prod.env -f docker-compose.yaml up -d --build"
|
||||||
|
|
||||||
cleanup_mr_environment:
|
cleanup_mr_environment:
|
||||||
name: Cleanup MR environment
|
name: Cleanup MR environment
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ services:
|
|||||||
- "--providers.docker=true"
|
- "--providers.docker=true"
|
||||||
- "--providers.docker.exposedbydefault=false"
|
- "--providers.docker.exposedbydefault=false"
|
||||||
- "--providers.docker.network=proxy"
|
- "--providers.docker.network=proxy"
|
||||||
- "--providers.docker.constraints=Label(`env`, `prod`)"
|
- "--providers.docker.constraints=Label(`env`, `${ENV}`)"
|
||||||
- "--entryPoints.web.address=:82"
|
- "--entryPoints.web.address=:80"
|
||||||
ports:
|
ports:
|
||||||
- "82:82"
|
- "${PORT}:80"
|
||||||
- "8081:8080"
|
- "8080"
|
||||||
volumes:
|
volumes:
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||||
|
|
||||||
@@ -25,10 +25,9 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- proxy
|
- proxy
|
||||||
labels:
|
labels:
|
||||||
- "env=prod"
|
- "env=${ENV}"
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
|
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
|
||||||
- "traefik.http.routers.whoami.entrypoints=web"
|
- "traefik.http.routers.whoami.entrypoints=web"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
proxy:
|
proxy:
|
||||||
3
staging.env
Normal file
3
staging.env
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
PORT=8080
|
||||||
|
ENV=staging
|
||||||
|
NETWORK_NAME=proxy
|
||||||
Reference in New Issue
Block a user