-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docker compose deploy related files.
- Loading branch information
Showing
5 changed files
with
101 additions
and
30 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
version: '2' | ||
version: "3.9" | ||
|
||
services: | ||
nginx-proxy: | ||
image: jwilder/nginx-proxy | ||
image: nginxproxy/nginx-proxy | ||
container_name: nginx-proxy | ||
restart: always | ||
ports: | ||
|
@@ -15,26 +15,32 @@ services: | |
- dhparam:/etc/nginx/dhparam | ||
- certs:/etc/nginx/certs:ro | ||
- /var/run/docker.sock:/tmp/docker.sock:ro | ||
network_mode: bridge | ||
labels: | ||
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" | ||
|
||
letsencrypt: | ||
image: jrcs/letsencrypt-nginx-proxy-companion:2.0 | ||
image: nginxproxy/acme-companion:2.2 | ||
container_name: nginx-proxy-le | ||
restart: always | ||
depends_on: | ||
- "nginx-proxy" | ||
environment: | ||
- [email protected] | ||
volumes_from: | ||
- nginx-proxy | ||
volumes: | ||
- certs:/etc/nginx/certs:rw | ||
- acme:/etc/acme.sh | ||
- vhost:/etc/nginx/vhost.d | ||
- html:/usr/share/nginx/html | ||
- /var/run/docker.sock:/var/run/docker.sock:ro | ||
network_mode: bridge | ||
|
||
networks: | ||
default: | ||
name: nginx | ||
|
||
volumes: | ||
conf: | ||
vhost: | ||
html: | ||
dhparam: | ||
certs: | ||
acme: | ||
acme: |
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 |
---|---|---|
|
@@ -34,7 +34,7 @@ jobs: | |
uses: actions/checkout@v3 | ||
with: | ||
ref: refs/tags/${{ github.event.inputs.version }} | ||
|
||
# Assign environment variables used in subsequent steps | ||
- name: Env variable assignment | ||
run: echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
|
@@ -48,7 +48,7 @@ jobs: | |
if [ "${{ github.event.inputs.version }}" != "" ]; then | ||
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV | ||
fi; | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
|
@@ -94,29 +94,27 @@ jobs: | |
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV | ||
fi; | ||
# Populate docker-compose.yml with variables from build process, including TAG_NAME. | ||
- name: docker-compose file prep | ||
uses: danielr1996/[email protected] | ||
env: | ||
RELEASE_VERSION: ${{ env.TAG_NAME }} | ||
IMAGE_REPO: ${{ env.image_repository_name }} | ||
APP_NAME: ${{ github.event.repository.name }} | ||
HOST_DOMAIN: ${{ env.domain }} | ||
LETSENCRYPT_EMAIL: ${{ env.letsencrypt_email }} | ||
with: | ||
input: .deploy/docker-compose-template.yml | ||
output: .deploy/${{ github.event.repository.name }}-docker-compose.yml | ||
- name: Create .env file | ||
run: | | ||
echo "Generating .env file" | ||
echo "# Autogenerated .env file" > .env | ||
echo "HOST_DOMAIN=${{ secrets.DEPLOY_HOST }}" >> .env | ||
echo "LETSENCRYPT_EMAIL=${{ secrets.LETSENCRYPT_EMAIL }}" >> .env | ||
echo "APP_NAME=${{ github.event.repository.name }}" >> .env | ||
echo "IMAGE_REPO=${{ env.image_repository_name }}" >> .env | ||
echo "RELEASE_VERSION=${{ env.TAG_NAME }}" >> .env | ||
# Copy only the docker-compose.yml to remote server home folder | ||
- name: copy compose file via scp | ||
- name: copy files to target server via scp | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.DEPLOY_HOST }} | ||
username: ${{ secrets.DEPLOY_USERNAME }} | ||
port: 22 | ||
key: ${{ secrets.DEPLOY_KEY }} | ||
source: ".deploy/${{ github.event.repository.name }}-docker-compose.yml" | ||
target: "~/" | ||
source: "./docker-compose.yml,./docker-compose.prod.yml,./.env" | ||
target: "~/.deploy/${{ github.event.repository.name }}/" | ||
|
||
- name: Run remote db migrations | ||
uses: appleboy/[email protected] | ||
|
@@ -131,10 +129,11 @@ jobs: | |
envs: APPTOKEN,USERNAME | ||
script: | | ||
echo $APPTOKEN | docker login ghcr.io -u $USERNAME --password-stdin | ||
docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml pull | ||
docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml up ${{ github.event.repository.name }}-migration | ||
cd ~/.deploy/${{ github.event.repository.name }} | ||
docker compose -f ./docker-compose.yml -f ./docker-compose.prod.yml pull | ||
docker compose -f ./docker-compose.yml -f ./docker-compose.prod.yml up app-migration | ||
# Deploy Docker image with ServiceStack application using `docker compose up` remotely | ||
# Deploy Docker image with your application using `docker compose up` remotely | ||
- name: remote docker-compose up via ssh | ||
uses: appleboy/[email protected] | ||
env: | ||
|
@@ -148,5 +147,6 @@ jobs: | |
envs: APPTOKEN,USERNAME | ||
script: | | ||
echo $APPTOKEN | docker login ghcr.io -u $USERNAME --password-stdin | ||
docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml pull | ||
docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml up -d | ||
cd ~/.deploy/${{ github.event.repository.name }} | ||
docker compose -f ./docker-compose.yml -f ./docker-compose.prod.yml pull | ||
docker compose -f ./docker-compose.yml -f ./docker-compose.prod.yml up app -d |
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,19 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
build: . | ||
ports: | ||
- "5000:80" | ||
volumes: | ||
- app-mydb:/app/App_Data | ||
app-migration: | ||
build: . | ||
restart: "no" | ||
profiles: | ||
- migration | ||
command: --AppTasks=migrate | ||
volumes: | ||
- app-mydb:/app/App_Data | ||
|
||
volumes: | ||
app-mydb: |
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,31 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
image: ghcr.io/${IMAGE_REPO}:${RELEASE_VERSION} | ||
restart: always | ||
ports: | ||
- "80" | ||
container_name: ${APP_NAME}_app | ||
environment: | ||
VIRTUAL_HOST: ${HOST_DOMAIN} | ||
LETSENCRYPT_HOST: ${HOST_DOMAIN} | ||
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} | ||
volumes: | ||
- app-mydb:/app/App_Data | ||
app-migration: | ||
image: ghcr.io/${IMAGE_REPO}:${RELEASE_VERSION} | ||
restart: "no" | ||
container_name: ${APP_NAME}_app_migration | ||
profiles: | ||
- migration | ||
command: --AppTasks=migrate | ||
volumes: | ||
- app-mydb:/app/App_Data | ||
|
||
networks: | ||
default: | ||
external: true | ||
name: nginx | ||
|
||
volumes: | ||
app-mydb: |
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,15 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
volumes: | ||
- app-mydb:/app/App_Data | ||
app-migration: | ||
restart: "no" | ||
profiles: | ||
- migration | ||
command: --AppTasks=migrate | ||
volumes: | ||
- app-mydb:/app/App_Data | ||
|
||
volumes: | ||
app-mydb: |