From b443929e0cb3c464d9cbe9d78ed52bb48078ca16 Mon Sep 17 00:00:00 2001 From: Rohan Batra <116573125+rohanbatrain@users.noreply.github.com> Date: Fri, 13 Jun 2025 11:06:13 +0530 Subject: [PATCH] Updated docker to use nginx as a reverse proxy --- .github/workflows/dev.yml | 9 +++---- .github/workflows/main.yml | 41 ++++++++++++++++++++++++++++ dev-environment/docker-compose.yml | 40 ++++++++++++++++++++++----- docker-compose.yml | 43 ++++++++++++++++++++++++------ 4 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index dd49590..3bf0d02 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,11 +1,10 @@ -name: Build and Push Docker Image to GHCR +name: Build and Push Docker Dev Image to GHCR # Trigger the action when pushing to the main branch on: push: branches: - dev - - main jobs: build: @@ -30,8 +29,8 @@ jobs: # Build and push Docker image to Docker Hub - name: Build and Push Docker image (Docker Hub) run: | - docker build -t rohanbatra/second_brain_database:latest . - docker push rohanbatra/second_brain_database:latest + docker build -t rohanbatra/second_brain_database:dev . + docker push rohanbatra/second_brain_database:dev - name: Publish to Github Registry uses: elgohr/Publish-Docker-Github-Action@v5 @@ -39,4 +38,4 @@ jobs: name: rohanbatrain/second_brain_database/dev username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - registry: ghcr.io + registry: ghcr.io \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..7855d10 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,41 @@ +name: Build and Push Docker Latest Image to GHCR + +# Trigger the action when pushing to the main branch +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Checkout the code from the repository + - name: Checkout code + uses: actions/checkout@v2 + + # Set up Docker Buildx (needed for building Docker images in GitHub Actions) + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Login to Docker Hub before building and pushing (good practice) + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: rohanbatra + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + # Build and push Docker image to Docker Hub + - name: Build and Push Docker image (Docker Hub) + run: | + docker build -t rohanbatra/second_brain_database:latest . + docker push rohanbatra/second_brain_database:latest + + - name: Publish to Github Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: rohanbatrain/second_brain_database + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io \ No newline at end of file diff --git a/dev-environment/docker-compose.yml b/dev-environment/docker-compose.yml index efb3038..93122fd 100644 --- a/dev-environment/docker-compose.yml +++ b/dev-environment/docker-compose.yml @@ -1,26 +1,52 @@ +version: "3.8" + services: mongo: image: mongo:latest container_name: mongo environment: - MONGO_INITDB_DATABASE=${MONGO_DB_NAME} - ports: - - "27017:27017" + networks: + - proxy + - default redis: image: redis:latest container_name: redis - ports: - - "6379:6379" + networks: + - proxy + - default second_brain_database: - image: rohanbatra/second_brain_database:dev # or use build: . if needed + image: rohanbatra/second_brain_database:dev container_name: second_brain_database - ports: - - "5000:5000" volumes: - ../../.sbd_config.json:/sbd_user/.config/Second-Brain-Database/.sbd_config.json:ro depends_on: - mongo - redis + networks: + - proxy + - default + + nginx_proxy_manager: + image: jc21/nginx-proxy-manager:latest + container_name: nginx_proxy_manager + restart: unless-stopped + ports: + - "80:80" # HTTP + - "443:443" # HTTPS + - "81:81" # Admin UI + volumes: + - npm_data:/data + - npm_letsencrypt:/etc/letsencrypt + networks: + - proxy + +networks: + proxy: + driver: bridge +volumes: + npm_data: + npm_letsencrypt: diff --git a/docker-compose.yml b/docker-compose.yml index 3c0be67..728e28a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,52 @@ +version: "3.8" + services: mongo: image: mongo:latest container_name: mongo environment: - MONGO_INITDB_DATABASE=${MONGO_DB_NAME} - ports: - - "27017:27017" + networks: + - proxy + - default redis: image: redis:latest container_name: redis - ports: - - "6379:6379" + networks: + - proxy + - default second_brain_database: - image: rohanbatra/second_brain_database:latest # or use build: . if needed + image: rohanbatra/second_brain_database:latest container_name: second_brain_database - ports: - - "5000:5000" volumes: - ./.sbd_config.json:/sbd_user/.config/Second-Brain-Database/.sbd_config.json:ro depends_on: - mongo - - redis \ No newline at end of file + - redis + networks: + - proxy + - default + + nginx_proxy_manager: + image: jc21/nginx-proxy-manager:latest + container_name: nginx_proxy_manager + restart: unless-stopped + ports: + - "80:80" + - "443:443" + - "81:81" + volumes: + - npm_data:/data + - npm_letsencrypt:/etc/letsencrypt + networks: + - proxy + +networks: + proxy: + driver: bridge + +volumes: + npm_data: + npm_letsencrypt: