-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
92 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
image: ghcr.io/${IMAGE_REPO}:${RELEASE_VERSION} | ||
restart: always | ||
# network_mode: bridge | ||
ports: | ||
- "8080" | ||
container_name: ${APP_NAME}_app | ||
environment: | ||
WS_HOST: ws://${HOST_DOMAIN} | ||
WS_PORT: 80 | ||
VIRTUAL_HOST: ${HOST_DOMAIN} | ||
VIRTUAL_PORT: 8080 # New default ASP.NET port -> https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port | ||
LETSENCRYPT_HOST: ${HOST_DOMAIN} | ||
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} | ||
LC_ALL: "en_US.UTF-8" | ||
LANG: "en_US.UTF-8" | ||
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 |
---|---|---|
@@ -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 |
---|---|---|
|
@@ -28,20 +28,15 @@ jobs: | |
# Checkout latest or specific tag | ||
- name: checkout | ||
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }} | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
- name: checkout tag | ||
if: ${{ github.event.inputs.version != '' && github.event.inputs.version != 'latest' }} | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: refs/tags/${{ github.event.inputs.version }} | ||
|
||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0' | ||
|
||
|
||
# Assign environment variables used in subsequent steps | ||
- name: repository name fix | ||
- name: Env variable assignment | ||
run: echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
# TAG_NAME defaults to 'latest' if not a release or manual deployment | ||
- name: Assign version | ||
|
@@ -54,59 +49,33 @@ jobs: | |
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV | ||
fi; | ||
- name: Run CI Prebuild Script | ||
env: | ||
deploy_api: ${{ secrets.DEPLOY_API }} | ||
run: | | ||
if [ -e ./.deploy/ci.prebuild.sh ] | ||
then | ||
chmod +x ./.deploy/ci.prebuild.sh | ||
./.deploy/ci.prebuild.sh | ||
else | ||
echo "Skipping CI prebuild" | ||
fi | ||
# Publish .NET Project | ||
- name: Publish dotnet project | ||
working-directory: ./world | ||
run: | | ||
dotnet publish -c Release /p:DEPLOY_API=${{ secrets.DEPLOY_API }} | ||
# Authenticate, build and push to GitHub Container Registry (ghcr.io) | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
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/[email protected] | ||
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }} | ||
with: | ||
file: Dockerfile | ||
context: . | ||
push: true | ||
tags: ghcr.io/${{ env.image_repository_name }}:${{ env.TAG_NAME }} | ||
|
||
- name: Build and push Docker image | ||
run: | | ||
dotnet publish --os linux --arch x64 -c Release -p:ContainerRepository=${{ env.image_repository_name }} -p:ContainerRegistry=ghcr.io -p:ContainerImageTags=${{ env.TAG_NAME }} -p:ContainerPort=80 | ||
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 | ||
- name: checkout | ||
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }} | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
- name: checkout tag | ||
if: ${{ github.event.inputs.version != '' && github.event.inputs.version != 'latest' }} | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: refs/tags/${{ github.event.inputs.version }} | ||
|
||
# Assign environment variables used in subsequent steps | ||
- name: repository name fix and env | ||
run: | | ||
echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
|
@@ -118,44 +87,43 @@ 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: ${{ secrets.DEPLOY_API }} | ||
LETSENCRYPT_EMAIL: ${{ secrets.LETSENCRYPT_EMAIL }} | ||
DEPLOY_API: ${{ secrets.DEPLOY_API }} | ||
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" > .deploy/.env | ||
echo "HOST_DOMAIN=${{ secrets.DEPLOY_HOST }}" >> .deploy/.env | ||
echo "LETSENCRYPT_EMAIL=${{ secrets.LETSENCRYPT_EMAIL }}" >> .deploy/.env | ||
echo "APP_NAME=${{ github.event.repository.name }}" >> .deploy/.env | ||
echo "IMAGE_REPO=${{ env.image_repository_name }}" >> .deploy/.env | ||
echo "RELEASE_VERSION=${{ env.TAG_NAME }}" >> .deploy/.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_API }} | ||
host: ${{ secrets.DEPLOY_HOST }} | ||
username: ${{ secrets.DEPLOY_USERNAME }} | ||
port: 22 | ||
key: ${{ secrets.DEPLOY_KEY }} | ||
source: ".deploy/${{ github.event.repository.name }}-docker-compose.yml" | ||
target: "~/" | ||
strip_components: 2 | ||
source: "./.deploy/docker-compose.yml,./.deploy/.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: | ||
APPTOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
USERNAME: ${{ secrets.DEPLOY_USERNAME }} | ||
with: | ||
host: ${{ secrets.DEPLOY_API }} | ||
host: ${{ secrets.DEPLOY_HOST }} | ||
username: ${{ secrets.DEPLOY_USERNAME }} | ||
key: ${{ secrets.DEPLOY_KEY }} | ||
port: 22 | ||
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 pull | ||
docker compose 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