diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..fe9a80f --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,45 @@ +name: "Publish" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +on: + push: + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.0.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker image for Proxy + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: ./energysmart-proxy + push: true + tags: ${{ steps.meta.outputs.tags }}-proxy + labels: ${{ steps.meta.outputs.labels }}-proxy \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 461e5cc..5316355 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,8 @@ services: restart: always energysmart-proxy: build: ./energysmart-proxy + environment: + - PROXY_PASS_LOCATION=energysmart-bridge:8001 ports: - "443:443" restart: always diff --git a/energysmart-proxy/Dockerfile b/energysmart-proxy/Dockerfile index 615a4eb..c5cbea3 100644 --- a/energysmart-proxy/Dockerfile +++ b/energysmart-proxy/Dockerfile @@ -2,10 +2,10 @@ FROM nginx:1.24 RUN apt-get update && apt-get install -y openssl -COPY nginx.conf /etc/nginx/ +COPY nginx.conf.template . RUN openssl req -nodes -new -x509 -sha1 -subj '/CN=energysmartwaterheater.com' -keyout /etc/nginx/energysmartwaterheater.com.key -out /etc/nginx/energysmartwaterheater.com.crt -days 3650 EXPOSE 443/tcp -CMD ["nginx", "-g", "daemon off;"] +CMD ["/bin/sh" , "-c" , "envsubst < /nginx.conf.template > /etc/nginx/nginx.conf && exec nginx -g 'daemon off;'"] diff --git a/energysmart-proxy/nginx.conf b/energysmart-proxy/nginx.conf.template similarity index 93% rename from energysmart-proxy/nginx.conf rename to energysmart-proxy/nginx.conf.template index e5cdb5a..25fc9fa 100644 --- a/energysmart-proxy/nginx.conf +++ b/energysmart-proxy/nginx.conf.template @@ -17,7 +17,7 @@ events { stream { server { listen 443 ssl; - proxy_pass energysmart-bridge:8001; + proxy_pass 192.168.0.241:8001; ssl_certificate /etc/nginx/energysmartwaterheater.com.crt; ssl_certificate_key /etc/nginx/energysmartwaterheater.com.key;