diff --git a/.github/workflows/build-and-publish-images.yml b/.github/workflows/build-and-publish-images.yml new file mode 100644 index 0000000..077b623 --- /dev/null +++ b/.github/workflows/build-and-publish-images.yml @@ -0,0 +1,25 @@ +# .github/workflows/build-and-publish-images.yml +name: Build and push to DockerHub + +on: + push: + branches: ["main"] + +jobs: + build_and_push_to_docker_hub: + name: Build and push to DockerHub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + - name: Set up Docker Build + uses: docker/setup-buildx-action@v2 + - name: Login to Docker + uses: docker/login-action@v2 + with: + username: findsimilar + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push to DockerHub + run: | + docker compose build + docker compose push \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5f01a88 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,37 @@ +# .github/workflows/deploy.yml +name: Deploy to production server + +on: + workflow_run: + workflows: ["Build and push to DockerHub"] + branches: ["main"] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Copy docker-compose.production.yml via ssh + uses: appleboy/scp-action@master + with: + host: ${{ secrets.DEPLOY_HOST }} + username: ${{ secrets.DEPLOY_USERNAME }} + password: ${{ secrets.DEPLOY_PASSWORD }} + port: ${{ secrets.DEPLOY_PORT }} + source: "docker-compose.production.yml" + target: "demo-gateway" + - name: Executing remote ssh commands to deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.DEPLOY_HOST }} + username: ${{ secrets.DEPLOY_USERNAME }} + password: ${{ secrets.DEPLOY_PASSWORD }} + port: ${{ secrets.DEPLOY_PORT }} + script: | + cd demo-gateway + docker compose -f docker-compose.production.yml pull + docker compose -f docker-compose.production.yml down + docker compose -f docker-compose.production.yml up -d \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf index adf9067..3b807ca 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,7 +1,3 @@ -upstream backend { - server 0.0.0.0:8000; -} - server { listen 80; server_name api.findsimilar.org;