Skip to content

Commit

Permalink
Merge pull request #133 from Lemoncode/develop
Browse files Browse the repository at this point in the history
Merge to main
  • Loading branch information
nasdan authored Jan 30, 2023
2 parents 94fce71 + 458dcb7 commit f1c01db
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 53 deletions.
39 changes: 25 additions & 14 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ on:
- main

env:
HEROKU_API_KEY: ${{secrets.HEROKU_API_KEY}}
IMAGE_NAME: registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
IMAGE_NAME: ghcr.io/lemoncode/english-quiz:prod-${{github.sha}}-${{github.run_attempt}}

permissions:
contents: 'read'
packages: 'write'

jobs:
cd:
Expand All @@ -17,18 +20,26 @@ jobs:
name: 'Production'
url: https://englishquiz.fun
steps:
- uses: actions/checkout@v2

- name: Install heroku and login
run: |
curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
heroku container:login
- name: Checkout repository
uses: actions/checkout@v3

- name: Build docker image
run: docker build -t ${{env.IMAGE_NAME}} .
- name: Log in to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy docker image
run: docker push ${{env.IMAGE_NAME}}
- name: Build and push docker image
run: |
docker build \
-t ${{env.IMAGE_NAME}} \
.
docker push ${{env.IMAGE_NAME}}
- name: Release
run: heroku container:release web -a ${{ secrets.HEROKU_APP_NAME }}
- name: Deploy to Azure
uses: azure/webapps-deploy@v2
with:
app-name: ${{ secrets.AZURE_APP_NAME }}
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
images: ${{env.IMAGE_NAME}}
3 changes: 2 additions & 1 deletion .github/workflows/dev-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
- name: Build and push docker image
run: |
docker build \
-t ${{env.IMAGE_NAME}} -f azure.Dockerfile .
-t ${{env.IMAGE_NAME}} \
.
docker push ${{env.IMAGE_NAME}}
- name: Deploy to Azure
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ COPY ./server/package.json ./
COPY ./server/index.js ./
RUN npm install --only=production

FROM nasdan/heroku-pm2-nginx
COPY --from=release /usr/app ./
FROM nasdan/azure-pm2-nginx
ENV NODE_ENV=production
ENV STATIC_FILES_PATH=./public
COPY --from=release /usr/app ./

COPY nginx.conf /etc/nginx/conf.d/default.conf

ENV INTERNAL_PORT=3000
RUN sed -i -e 's|INTERNAL_PORT|'"$INTERNAL_PORT"'|g' /etc/nginx/conf.d/default.conf

CMD bash docker-entrypoint.sh && \
sed -i -e 's|PORT|'"$PORT"'|g' /etc/nginx/conf.d/default.conf && \
CMD sh docker-entrypoint.sh && \
sed -i -e 's|PORT|80|g' /etc/nginx/conf.d/default.conf && \
pm2 start ./index.js --name "app" --env production && \
nginx -g 'daemon off;'

34 changes: 0 additions & 34 deletions azure.Dockerfile

This file was deleted.

0 comments on commit f1c01db

Please sign in to comment.