Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NetCoreTemplates/nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 30, 2023
2 parents 61f7e83 + b9e477e commit 7bb14d5
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .deploy/ci.prebuild.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sed -i "s/\$DEPLOY_API/${deploy_api}/g" ./ui/next.config.js
sed -i "s/\$DEPLOY_API/${deploy_api}/g" ./ui/next.config.mjs
[[ -f ./ui/post.build.js ]] && sed -i "s/\$DEPLOY_API/${deploy_api}/g;s/\$DEPLOY_CDN/${deploy_cdn}/g" ./ui/post.build.js
27 changes: 0 additions & 27 deletions .deploy/docker-compose-template.yml

This file was deleted.

22 changes: 14 additions & 8 deletions .deploy/nginx-proxy-compose.yml
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:
Expand All @@ -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:
50 changes: 24 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
working-directory: ./ui

# 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
Expand All @@ -75,14 +75,13 @@ jobs:
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV
fi;
# Authenticate, build and push to GitHub Container Registry (ghcr.io)
- name: Login to GitHub Container Registry
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@v3
Expand Down Expand Up @@ -120,7 +119,6 @@ jobs:
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
Expand All @@ -132,31 +130,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: ${{ secrets.DEPLOY_API }}
LETSENCRYPT_EMAIL: ${{ secrets.LETSENCRYPT_EMAIL }}
DEPLOY_API: ${{ secrets.DEPLOY_API }}
DEPLOY_CDN: ${{ secrets.DEPLOY_CDN }}
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_API }}" >> .env
echo "DEPLOY_API=${{ secrets.DEPLOY_API }}" >> .env
echo "DEPLOY_CDN=${{ secrets.DEPLOY_CDN }}" >> .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_API }}
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]
Expand All @@ -171,10 +167,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 --exit-code-from ${{ 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:
Expand All @@ -188,5 +185,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
19 changes: 19 additions & 0 deletions docker-compose.override.yml
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:
33 changes: 33 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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}
DEPLOY_API: ${DEPLOY_API}
DEPLOY_CDN: ${DEPLOY_CDN}
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:
15 changes: 15 additions & 0 deletions docker-compose.yml
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:

0 comments on commit 7bb14d5

Please sign in to comment.