Skip to content

Commit

Permalink
Merge pull request #23 from dereckmezquita/DN-2-nextjs-14-app-dir
Browse files Browse the repository at this point in the history
DN-2: nextjs 14 app dir
  • Loading branch information
dereckmezquita committed Jun 24, 2024
2 parents 6d7c80e + d800108 commit 1f51d0c
Show file tree
Hide file tree
Showing 2,746 changed files with 12,432 additions and 90,952 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
Dockerfile*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
38 changes: 8 additions & 30 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
## Description
# jira ticket

Please include a summary of the changes and which issue is fixed. Also, include relevant motivation and context.
https://singular-ai.atlassian.net/browse/<TICKET-ID>

Fixes # (issue)
# todo list

## Type of Change
- [ ] Version bump
- [ ] Clean up code

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Breaking Change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation Update
- [ ] Other (Please describe)
# tests updated

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

- [ ] Test A
- [ ] Test B

**Test Configuration**:
- Operating System:
- Node version:
- Other:

## Checklist

- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] integration test
- [ ] unit test
119 changes: 119 additions & 0 deletions .github/workflows/release_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Release Dev Docker image to Linode

on:
push:
branches-ignore:
- 'master'
env:
IMAGE_NAME_SERVER: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-server
IMAGE_NAME_CLIENT: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-client
CONTAINER_NAME_SERVER: dev_linode_derecksnotes-server
CONTAINER_NAME_CLIENT: dev_linode_derecksnotes-client

jobs:
push_to_registry_server:
name: Push Docker server image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create .env file
run: |
echo BUILD_ENV=DEV > ./server/.env
echo API_URL=https://dev.derecksnotes.com/api/ >> ./server/.env
echo SESSION_SECRET=${{ secrets.SESSION_SECRET }} >> ./server/.env
echo MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }} >> ./server/.env
- name: Build and push server image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./
file: ./server/Dockerfile
push: true
tags: ${{ env.IMAGE_NAME_SERVER }}:latest_dev

push_to_registry_client:
name: Push Docker client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create .env file
run: |
echo NEXT_PUBLIC_BUILD_ENV=DEV > ./client/.env
echo NEXT_PUBLIC_APP_URL=https://dev.derecksnotes.com/ >> ./client/.env
echo NEXT_PUBLIC_API_URL=https://dev.derecksnotes.com/api/ >> ./client/.env
- name: Build and push client image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./
file: ./client/Dockerfile
push: true
tags: ${{ env.IMAGE_NAME_CLIENT }}:latest_dev

deploy_to_linode:
name: Deploy docker-compose.yml to Linode
needs: [push_to_registry_server, push_to_registry_client]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Create .env file for docker-compose deployment
run: |
echo IMAGE_NAME_SERVER=${{ env.IMAGE_NAME_SERVER }}:latest_dev > .env
echo IMAGE_NAME_CLIENT=${{ env.IMAGE_NAME_CLIENT }}:latest_dev >> .env
echo CONTAINER_NAME_SERVER=${{ env.CONTAINER_NAME_SERVER }} >> .env
echo CONTAINER_NAME_CLIENT=${{ env.CONTAINER_NAME_CLIENT }} >> .env
echo PORT_MAP_SERVER=3001 >> .env
echo PORT_MAP_CLIENT=3000 >> .env
- name: Copy docker-compose.yml to remote server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
password: ${{ secrets.REMOTE_PASSWORD }}
port: ${{ secrets.REMOTE_PORT }}
source: './docker-compose.yml, .env'
target: '/root/dev_docker-compose-derecksnotes/'

- name: Deploy to remote server
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
password: ${{ secrets.REMOTE_PASSWORD }}
port: ${{ secrets.REMOTE_PORT }}
command_timeout: 20m
script: |
cd /root/dev_docker-compose-derecksnotes/
docker pull ${{ env.IMAGE_NAME_SERVER }}:latest_dev
docker pull ${{ env.IMAGE_NAME_CLIENT }}:latest_dev
docker container prune -f
docker system prune -af
docker rm -f ${{ env.CONTAINER_NAME_SERVER }} || true
docker rm -f ${{ env.CONTAINER_NAME_CLIENT }} || true
docker compose --env-file .env --project-name derecksnotes-dev down
docker compose --env-file .env --project-name derecksnotes-dev up -d
131 changes: 131 additions & 0 deletions .github/workflows/release_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Release Prod Docker image to Linode

on:
release:
types: [published]
# on:
# push:
# branches-ignore:
# - 'master'
env:
IMAGE_NAME_SERVER: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-server
IMAGE_NAME_CLIENT: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-client
CONTAINER_NAME_SERVER: prod_linode_derecksnotes-server
CONTAINER_NAME_CLIENT: prod_linode_derecksnotes-client

jobs:
push_to_registry_server:
name: Push Docker server image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create .env file
run: |
echo BUILD_ENV=PROD > ./server/.env
echo API_URL=https://derecksnotes.com/api/ >> ./server/.env
echo SESSION_SECRET=${{ secrets.SESSION_SECRET }} >> ./server/.env
echo MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }} >> ./server/.env
- name: Build and push server image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./server
file: ./server/Dockerfile
push: true
tags: ${{ env.IMAGE_NAME_SERVER }}:latest_prod
build-args: |
BUILD_ENV=PROD
API_URL=https://derecksnotes.com/api/
SESSION_SECRET=${{ secrets.SESSION_SECRET }}
MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }}
push_to_registry_client:
name: Push Docker client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create .env file
run: |
echo NEXT_PUBLIC_BUILD_ENV=PROD > ./client/.env
echo NEXT_PUBLIC_APP_URL=https://derecksnotes.com/ >> ./client/.env
echo NEXT_PUBLIC_API_URL=https://derecksnotes.com/api/ >> ./client/.env
- name: Build and push client image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./
file: ./client/Dockerfile
push: true
tags: ${{ env.IMAGE_NAME_CLIENT }}:latest_prod
build-args: |
NEXT_PUBLIC_BUILD_ENV=PROD
NEXT_PUBLIC_APP_URL=https://derecksnotes.com/
NEXT_PUBLIC_API_URL=https://derecksnotes.com/api/
deploy_to_linode:
name: Deploy docker-compose.yml to Linode
needs: [push_to_registry_server, push_to_registry_client]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Create .env file for docker-compose deployment
run: |
echo IMAGE_NAME_SERVER=${{ env.IMAGE_NAME_SERVER }}:latest_prod > .env
echo IMAGE_NAME_CLIENT=${{ env.IMAGE_NAME_CLIENT }}:latest_prod >> .env
echo CONTAINER_NAME_SERVER=${{ env.CONTAINER_NAME_SERVER }} >> .env
echo CONTAINER_NAME_CLIENT=${{ env.CONTAINER_NAME_CLIENT }} >> .env
echo PORT_MAP_SERVER=3003 >> .env
echo PORT_MAP_CLIENT=3002 >> .env
- name: Copy docker-compose.yml to remote server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
password: ${{ secrets.REMOTE_PASSWORD }}
port: ${{ secrets.REMOTE_PORT }}
source: './docker-compose.yml, .env'
target: '/root/prod_docker-compose-derecksnotes/'

- name: Deploy to remote server
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
password: ${{ secrets.REMOTE_PASSWORD }}
port: ${{ secrets.REMOTE_PORT }}
command_timeout: 20m
script: |
cd /root/prod_docker-compose-derecksnotes/
docker pull ${{ env.IMAGE_NAME_SERVER }}:latest_prod
docker pull ${{ env.IMAGE_NAME_CLIENT }}:latest_prod
docker container prune -f
docker system prune -af
docker rm -f ${{ env.CONTAINER_NAME_SERVER }} || true
docker rm -f ${{ env.CONTAINER_NAME_CLIENT }} || true
docker compose --env-file .env --project-name derecksnotes-prod down
docker compose --env-file .env --project-name derecksnotes-prod up -d
Loading

0 comments on commit 1f51d0c

Please sign in to comment.