Skip to content

Commit fdd1adf

Browse files
committed
Update docker compose deploy related files.
1 parent 7a1023f commit fdd1adf

File tree

6 files changed

+84
-52
lines changed

6 files changed

+84
-52
lines changed

.deploy/docker-compose-template.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.deploy/nginx-proxy-compose.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
version: '2'
1+
version: "3.9"
22

33
services:
44
nginx-proxy:
5-
image: jwilder/nginx-proxy
5+
image: nginxproxy/nginx-proxy
66
container_name: nginx-proxy
77
restart: always
88
ports:
@@ -15,26 +15,32 @@ services:
1515
- dhparam:/etc/nginx/dhparam
1616
- certs:/etc/nginx/certs:ro
1717
- /var/run/docker.sock:/tmp/docker.sock:ro
18-
network_mode: bridge
18+
labels:
19+
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
1920

2021
letsencrypt:
21-
image: jrcs/letsencrypt-nginx-proxy-companion:2.0
22+
image: nginxproxy/acme-companion:2.2
2223
container_name: nginx-proxy-le
2324
restart: always
25+
depends_on:
26+
- "nginx-proxy"
2427
environment:
2528
26-
volumes_from:
27-
- nginx-proxy
2829
volumes:
2930
- certs:/etc/nginx/certs:rw
3031
- acme:/etc/acme.sh
32+
- vhost:/etc/nginx/vhost.d
33+
- html:/usr/share/nginx/html
3134
- /var/run/docker.sock:/var/run/docker.sock:ro
32-
network_mode: bridge
35+
36+
networks:
37+
default:
38+
name: nginx
3339

3440
volumes:
3541
conf:
3642
vhost:
3743
html:
3844
dhparam:
3945
certs:
40-
acme:
46+
acme:

.github/workflows/release.yml

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ on:
2222

2323
jobs:
2424
push_to_registry:
25-
runs-on: ubuntu-20.04
25+
runs-on: ubuntu-22.04
2626
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
2727
steps:
2828
# Checkout latest or specific tag
2929
- name: checkout
3030
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }}
31-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
3232
- name: checkout tag
3333
if: ${{ github.event.inputs.version != '' && github.event.inputs.version != 'latest' }}
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v3
3535
with:
3636
ref: refs/tags/${{ github.event.inputs.version }}
37-
37+
3838
# Assign environment variables used in subsequent steps
3939
- name: Env variable assignment
4040
run: echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
@@ -58,44 +58,42 @@ jobs:
5858
run: |
5959
npm run build
6060
working-directory: ./MyApp
61-
61+
6262
- name: Login to GitHub Container Registry
63-
uses: docker/login-action@v1
63+
uses: docker/login-action@v2
6464
with:
6565
registry: ghcr.io
6666
username: ${{ github.actor }}
6767
password: ${{ secrets.GITHUB_TOKEN }}
6868

6969
# Build and push new docker image, skip for manual redeploy other than 'latest'
7070
- name: Build and push Docker images
71-
uses: docker/build-push-action@v2.2.2
71+
uses: docker/build-push-action@v3
7272
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }}
7373
with:
7474
file: Dockerfile
7575
context: .
7676
push: true
7777
tags: ghcr.io/${{ env.image_repository_name }}:${{ env.TAG_NAME }}
78-
78+
7979
deploy_via_ssh:
8080
needs: push_to_registry
81-
runs-on: ubuntu-20.04
81+
runs-on: ubuntu-22.04
8282
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
8383
steps:
8484
# Checkout latest or specific tag
8585
- name: checkout
8686
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }}
87-
uses: actions/checkout@v2
87+
uses: actions/checkout@v3
8888
- name: checkout tag
8989
if: ${{ github.event.inputs.version != '' && github.event.inputs.version != 'latest' }}
90-
uses: actions/checkout@v2
90+
uses: actions/checkout@v3
9191
with:
9292
ref: refs/tags/${{ github.event.inputs.version }}
9393

9494
- name: repository name fix and env
9595
run: |
9696
echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
97-
echo "domain=${{ secrets.DEPLOY_HOST }}" >> $GITHUB_ENV
98-
echo "letsencrypt_email=${{ secrets.LETSENCRYPT_EMAIL }}" >> $GITHUB_ENV
9997
echo "TAG_NAME=latest" >> $GITHUB_ENV
10098
if [ "${{ github.event.release.tag_name }}" != "" ]; then
10199
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
@@ -104,33 +102,31 @@ jobs:
104102
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV
105103
fi;
106104
107-
# Populate docker-compose.yml with variables from build process, including TAG_NAME.
108-
- name: docker-compose file prep
109-
uses: danielr1996/[email protected]
110-
env:
111-
RELEASE_VERSION: ${{ env.TAG_NAME }}
112-
IMAGE_REPO: ${{ env.image_repository_name }}
113-
APP_NAME: ${{ github.event.repository.name }}
114-
HOST_DOMAIN: ${{ env.domain }}
115-
LETSENCRYPT_EMAIL: ${{ env.letsencrypt_email }}
116-
with:
117-
input: .deploy/docker-compose-template.yml
118-
output: .deploy/${{ github.event.repository.name }}-docker-compose.yml
105+
- name: Create .env file
106+
run: |
107+
echo "Generating .env file"
108+
109+
echo "#Autogenerated .env file" > .env
110+
echo "HOST_DOMAIN=${{ secrets.DEPLOY_HOST }}" >> .env
111+
echo "LETSENCRYPT_EMAIL=${{ secrets.LETSENCRYPT_EMAIL }}" >> .env
112+
echo "APP_NAME=${{ github.event.repository.name }}" >> .env
113+
echo "IMAGE_REPO=${{ env.image_repository_name }}" >> .env
114+
echo "RELEASE_VERSION=${{ env.TAG_NAME }}" >> .env
119115
120116
# Copy only the docker-compose.yml to remote server home folder
121-
- name: copy compose file via scp
117+
- name: copy files to target server via scp
122118
uses: appleboy/[email protected]
123119
with:
124120
host: ${{ secrets.DEPLOY_HOST }}
125121
username: ${{ secrets.DEPLOY_USERNAME }}
126122
port: 22
127123
key: ${{ secrets.DEPLOY_KEY }}
128-
source: ".deploy/${{ github.event.repository.name }}-docker-compose.yml"
129-
target: "~/"
124+
source: "./docker-compose.yml,./docker-compose.prod.yml,./.env"
125+
target: "~/.deploy/${{ github.event.repository.name }}/"
130126

131-
# Deploy Docker image with ServiceStack application using `docker compose up` remotely
127+
# Deploy Docker image with your application using `docker compose up` remotely
132128
- name: remote docker-compose up via ssh
133-
uses: appleboy/[email protected].4
129+
uses: appleboy/[email protected].5
134130
env:
135131
APPTOKEN: ${{ secrets.GITHUB_TOKEN }}
136132
USERNAME: ${{ secrets.DEPLOY_USERNAME }}
@@ -142,5 +138,6 @@ jobs:
142138
envs: APPTOKEN,USERNAME
143139
script: |
144140
echo $APPTOKEN | docker login ghcr.io -u $USERNAME --password-stdin
145-
docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml pull
146-
docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml up -d
141+
cd ~/.deploy/${{ github.event.repository.name }}
142+
docker compose -f ./docker-compose.yml -f ./docker-compose.prod.yml pull
143+
docker compose -f ./docker-compose.yml -f ./docker-compose.prod.yml up app -d

docker-compose.override.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3.9"
2+
services:
3+
app:
4+
build: .
5+
ports:
6+
- "5000:80"
7+
volumes:
8+
- app-mydb:/app/App_Data
9+
10+
volumes:
11+
app-mydb:

docker-compose.prod.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "3.9"
2+
services:
3+
app:
4+
image: ghcr.io/${IMAGE_REPO}:${RELEASE_VERSION}
5+
restart: always
6+
ports:
7+
- "80"
8+
container_name: ${APP_NAME}_app
9+
environment:
10+
VIRTUAL_HOST: ${HOST_DOMAIN}
11+
LETSENCRYPT_HOST: ${HOST_DOMAIN}
12+
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
13+
volumes:
14+
- app-mydb:/app/App_Data
15+
16+
networks:
17+
default:
18+
external: true
19+
name: nginx
20+
21+
volumes:
22+
app-mydb:

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: "3.9"
2+
services:
3+
app:
4+
volumes:
5+
- app-mydb:/app/App_Data
6+
7+
volumes:
8+
app-mydb:

0 commit comments

Comments
 (0)