-
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.
Update docker compose deploy related files.
- Loading branch information
Showing
7 changed files
with
71 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ on: | |
|
||
jobs: | ||
push_to_registry: | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-22.04 | ||
if: ${{ github.event.workflow_run.conclusion != 'failure' }} | ||
steps: | ||
# Checkout latest or specific tag | ||
|
@@ -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 | ||
|
@@ -49,26 +49,16 @@ jobs: | |
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV | ||
fi; | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
# Run postinstall script | ||
- name: Install and build npm | ||
run: | | ||
npm install | ||
working-directory: ./MyApp | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Build and push new docker image, skip for manual redeploy other than 'latest' | ||
- name: Build and push Docker images | ||
uses: docker/build-push-action@v2.2.2 | ||
uses: docker/build-push-action@v3 | ||
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }} | ||
with: | ||
file: Dockerfile | ||
|
@@ -78,7 +68,7 @@ jobs: | |
|
||
deploy_via_ssh: | ||
needs: push_to_registry | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-22.04 | ||
if: ${{ github.event.workflow_run.conclusion != 'failure' }} | ||
steps: | ||
# Checkout latest or specific tag | ||
|
@@ -104,31 +94,29 @@ 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 }}/" | ||
|
||
# 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: | ||
|
@@ -142,5 +130,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
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,6 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
build: . | ||
ports: | ||
- "5000:80" |
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,17 @@ | ||
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} | ||
|
||
networks: | ||
default: | ||
external: true | ||
name: nginx |
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,4 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
container_name: my_app |