diff --git a/.env b/.env index f2b86087..c6b2cdba 100644 --- a/.env +++ b/.env @@ -30,10 +30,8 @@ NATS_URL=nats:4222 INTERNAL_BACKEND_BASE_URL=https://backend.tarhche.com NEXT_PUBLIC_FILES_PROTOCOL=https NEXT_PUBLIC_FILES_HOST=backend.tarhche.com -NEXT_PUBLIC_FILES_PORT=80 ## frontend local # INTERNAL_BACKEND_BASE_URL=http://app # NEXT_PUBLIC_FILES_PROTOCOL=http # NEXT_PUBLIC_FILES_HOST=127.0.0.1 -# NEXT_PUBLIC_FILES_PORT=8000 diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index d7c4f438..e452fbfa 100644 --- a/.github/workflows/backend.yaml +++ b/.github/workflows/backend.yaml @@ -91,7 +91,7 @@ jobs: - name: Deploy services run: | # Setup ssh key - echo "${{ secrets.EC2_SSH_PRIVATE_KEY }}" > ~/ec2-key.pem + echo '${{ secrets.EC2_SSH_PRIVATE_KEY }}' > ~/ec2-key.pem chmod 400 ~/ec2-key.pem mkdir -p ~/.ssh @@ -109,32 +109,32 @@ jobs: # Connect and deploy services ssh -q -i ~/ec2-key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $EC2_SSH_ENDPOINT > /dev/null 2>&1 << 'EOF' - export MONGO_USERNAME="${{ secrets.MONGO_USERNAME }}" - export MONGO_PASSWORD="${{ secrets.MONGO_PASSWORD }}" - - export BACKEND_NATS_URL="${{ secrets.BACKEND_NATS_URL }}" - export BACKEND_PRIVATE_KEY="${{ secrets.BACKEND_PRIVATE_KEY }}" - - export BACKEND_MONGO_HOST="mongodb" - export BACKEND_MONGO_PORT="27017" - export BACKEND_MONGO_SCHEME="mongodb" - export BACKEND_MONGO_DATABASE_NAME="${{ secrets.BACKEND_MONGO_DATABASE_NAME }}" - export BACKEND_MONGO_USERNAME="${{ secrets.MONGO_USERNAME }}" - export BACKEND_MONGO_PASSWORD="${{ secrets.MONGO_PASSWORD }}" - - export BACKEND_MAIL_SMTP_PASSWORD="${{ secrets.BACKEND_MAIL_SMTP_PASSWORD }}" - export BACKEND_MAIL_SMTP_HOST="${{ secrets.BACKEND_MAIL_SMTP_HOST }}" - export BACKEND_MAIL_SMTP_FROM="${{ secrets.BACKEND_MAIL_SMTP_FROM }}" - export BACKEND_MAIL_SMTP_USERNAME="${{ secrets.BACKEND_MAIL_SMTP_USERNAME }}" - export BACKEND_MAIL_SMTP_PORT="${{ secrets.BACKEND_MAIL_SMTP_PORT }}" - - export BACKEND_S3_ENDPOINT="${{ secrets.BACKEND_S3_ENDPOINT }}" - export BACKEND_S3_SECRET_KEY="${{ secrets.BACKEND_S3_SECRET_KEY }}" - export BACKEND_S3_ACCESS_KEY="${{ secrets.BACKEND_S3_ACCESS_KEY }}" - export BACKEND_S3_USE_SSL="${{ secrets.BACKEND_S3_USE_SSL }}" - export BACKEND_S3_BUCKET_NAME="${{ secrets.BACKEND_S3_BUCKET_NAME }}" - - export APP_IMAGE="${{ secrets.APP_IMAGE }}" + export MONGO_USERNAME='${{ secrets.MONGO_USERNAME }}' + export MONGO_PASSWORD='${{ secrets.MONGO_PASSWORD }}' + + export BACKEND_NATS_URL='${{ secrets.BACKEND_NATS_URL }}' + export BACKEND_PRIVATE_KEY='${{ secrets.BACKEND_PRIVATE_KEY }}' + + export BACKEND_MONGO_HOST='mongodb' + export BACKEND_MONGO_PORT='27017' + export BACKEND_MONGO_SCHEME='mongodb' + export BACKEND_MONGO_DATABASE_NAME='${{ secrets.BACKEND_MONGO_DATABASE_NAME }}' + export BACKEND_MONGO_USERNAME='${{ secrets.MONGO_USERNAME }}' + export BACKEND_MONGO_PASSWORD='${{ secrets.MONGO_PASSWORD }}' + + export BACKEND_MAIL_SMTP_PASSWORD='${{ secrets.BACKEND_MAIL_SMTP_PASSWORD }}' + export BACKEND_MAIL_SMTP_HOST='${{ secrets.BACKEND_MAIL_SMTP_HOST }}' + export BACKEND_MAIL_SMTP_FROM='${{ secrets.BACKEND_MAIL_SMTP_FROM }}' + export BACKEND_MAIL_SMTP_USERNAME='${{ secrets.BACKEND_MAIL_SMTP_USERNAME }}' + export BACKEND_MAIL_SMTP_PORT='${{ secrets.BACKEND_MAIL_SMTP_PORT }}' + + export BACKEND_S3_ENDPOINT='${{ secrets.BACKEND_S3_ENDPOINT }}' + export BACKEND_S3_SECRET_KEY='${{ secrets.BACKEND_S3_SECRET_KEY }}' + export BACKEND_S3_ACCESS_KEY='${{ secrets.BACKEND_S3_ACCESS_KEY }}' + export BACKEND_S3_USE_SSL='${{ secrets.BACKEND_S3_USE_SSL }}' + export BACKEND_S3_BUCKET_NAME='${{ secrets.BACKEND_S3_BUCKET_NAME }}' + + export APP_IMAGE='${{ secrets.APP_IMAGE }}' # Run Docker Compose cd /tmp/deployment_backend/ diff --git a/.github/workflows/frontend.yaml b/.github/workflows/frontend.yaml index 5eee3cab..3899c86f 100644 --- a/.github/workflows/frontend.yaml +++ b/.github/workflows/frontend.yaml @@ -21,6 +21,10 @@ env: EC2_SSH_ADDRESS: ${{ secrets.EC2_SSH_ADDRESS }} EC2_SSH_ENDPOINT: ${{ secrets.EC2_SSH_USER }}@${{ secrets.EC2_SSH_ADDRESS }} + INTERNAL_BACKEND_BASE_URL: ${{ secrets.INTERNAL_BACKEND_BASE_URL }} + NEXT_PUBLIC_FILES_PROTOCOL: https + NEXT_PUBLIC_FILES_HOST: ${{ secrets.NEXT_PUBLIC_FILES_HOST }} + jobs: ci: runs-on: ubuntu-latest @@ -82,7 +86,7 @@ jobs: - name: Deploy services run: | # Setup ssh key - echo "${{ secrets.EC2_SSH_PRIVATE_KEY }}" > ~/ec2-key.pem + echo '${{ secrets.EC2_SSH_PRIVATE_KEY }}' > ~/ec2-key.pem chmod 400 ~/ec2-key.pem mkdir -p ~/.ssh @@ -99,10 +103,10 @@ jobs: # Connect and deploy services ssh -q -i ~/ec2-key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $EC2_SSH_ENDPOINT > /dev/null 2>&1 << 'EOF' - export FRONTEND_IMAGE="${{ secrets.FRONTEND_IMAGE }}" - export NEXT_PUBLIC_EXTERNAL_BACKEND_BASE_URL="${{ secrets.NEXT_PUBLIC_EXTERNAL_BACKEND_BASE_URL }}" - export INTERNAL_BACKEND_BASE_URL="${{ secrets.INTERNAL_BACKEND_BASE_URL }}" - export NEXT_PUBLIC_FILES_BASE_URL="${{ secrets.NEXT_PUBLIC_FILES_BASE_URL }}" + export FRONTEND_IMAGE='${{ secrets.FRONTEND_IMAGE }}' + export INTERNAL_BACKEND_BASE_URL='${{ env.INTERNAL_BACKEND_BASE_URL }}' + export NEXT_PUBLIC_FILES_PROTOCOL='${{ env.NEXT_PUBLIC_FILES_PROTOCOL }}' + export NEXT_PUBLIC_FILES_HOST='${{ env.NEXT_PUBLIC_FILES_HOST }}' # Run Docker Compose cd /tmp/deployment_frontend/ diff --git a/compose.yaml b/compose.yaml index 9fb6ca46..0a8114be 100644 --- a/compose.yaml +++ b/compose.yaml @@ -48,7 +48,6 @@ services: INTERNAL_BACKEND_BASE_URL: ${INTERNAL_BACKEND_BASE_URL} NEXT_PUBLIC_FILES_PROTOCOL: ${NEXT_PUBLIC_FILES_PROTOCOL} NEXT_PUBLIC_FILES_HOST: ${NEXT_PUBLIC_FILES_HOST} - NEXT_PUBLIC_FILES_PORT: ${NEXT_PUBLIC_FILES_PORT} command: > sh -c "npm install; npm run dev -- --hostname \"0.0.0.0\" --port 3000" diff --git a/frontend/.env.local.example b/frontend/.env.local.example index 9769d98d..84a29ce9 100644 --- a/frontend/.env.local.example +++ b/frontend/.env.local.example @@ -1,4 +1,3 @@ INTERNAL_BACKEND_BASE_URL=https://backend.tarhche.com NEXT_PUBLIC_FILES_PROTOCOL=https NEXT_PUBLIC_FILES_HOST=backend.tarhche.com -NEXT_PUBLIC_FILES_PORT=80 diff --git a/frontend/compose.frontend.yaml b/frontend/compose.frontend.yaml index eb396d2d..b2155cf7 100644 --- a/frontend/compose.frontend.yaml +++ b/frontend/compose.frontend.yaml @@ -13,9 +13,9 @@ services: delay: 5s max_attempts: 3 environment: - NEXT_PUBLIC_EXTERNAL_BACKEND_BASE_URL: ${NEXT_PUBLIC_EXTERNAL_BACKEND_BASE_URL} INTERNAL_BACKEND_BASE_URL: ${INTERNAL_BACKEND_BASE_URL} - NEXT_PUBLIC_FILES_BASE_URL: ${NEXT_PUBLIC_FILES_BASE_URL} + NEXT_PUBLIC_FILES_PROTOCOL: ${NEXT_PUBLIC_FILES_PROTOCOL} + NEXT_PUBLIC_FILES_HOST: ${NEXT_PUBLIC_FILES_HOST} networks: frontend: diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 98c889e3..354c3602 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -8,7 +8,6 @@ const nextConfig = { { protocol: process.env.NEXT_PUBLIC_FILES_PROTOCOL, hostname: process.env.NEXT_PUBLIC_FILES_HOST, - port: process.env.NEXT_PUBLIC_FILES_PORT, }, ], }, diff --git a/frontend/src/constants/envs.ts b/frontend/src/constants/envs.ts index 8def7fe8..e408dd91 100644 --- a/frontend/src/constants/envs.ts +++ b/frontend/src/constants/envs.ts @@ -1,2 +1,2 @@ export const INTERNAL_BACKEND_URL = process.env.INTERNAL_BACKEND_BASE_URL; -export const FILES_PUBLIC_URL = `${process.env.NEXT_PUBLIC_FILES_PROTOCOL}://${process.env.NEXT_PUBLIC_FILES_HOST}:${process.env.NEXT_PUBLIC_FILES_PORT}/files`; +export const FILES_PUBLIC_URL = `${process.env.NEXT_PUBLIC_FILES_PROTOCOL}://${process.env.NEXT_PUBLIC_FILES_HOST}/files`;