Skip to content

Commit

Permalink
Merge pull request #5 from renatohberg/05-Docker
Browse files Browse the repository at this point in the history
05 docker
  • Loading branch information
renatohberg authored Nov 21, 2023
2 parents b295441 + 1c3b71c commit 1774337
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.git
.github
.gitignore
LICENSE
README.md
test.py
35 changes: 35 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,38 @@ jobs:

- name: Unit Test
run: python -m unittest -v test

- name: Docker Login
run: |
echo '${{ secrets.GOOGLE_CREDENTIALS }}' > key.json
cat key.json | docker login -u _json_key --password-stdin '${{ vars.GOOGLE_ARTIFACT }}'
- name: Build & Push Image
run: |
docker build -t ${{ vars.GOOGLE_ARTIFACT }}/${{ vars.GOOGLE_PROJECT_ID }}/${{ vars.GOOGLE_REPONAME }}/${{ vars.GOOGLE_MYAPP }}:latest .
docker push ${{ vars.GOOGLE_ARTIFACT }}/${{ vars.GOOGLE_PROJECT_ID }}/${{ vars.GOOGLE_REPONAME }}/${{ vars.GOOGLE_MYAPP }}:latest
Deploy:
needs: Build
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3 # https://github.com/actions/checkout

- name: Auth GCP
uses: 'google-github-actions/auth@v1' # https://github.com/google-github-actions/auth
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

- name: Cloud Run Deploy
id: deploy
run: |-
gcloud run deploy ${{ vars.GOOGLE_MYAPP }} \
--quiet \
--region ${{ vars.GOOGLE_REGION }} \
--image ${{ vars.GOOGLE_ARTIFACT }}/${{ vars.GOOGLE_PROJECT_ID }}/${{ vars.GOOGLE_REPONAME }}/${{ vars.GOOGLE_MYAPP }}:latest \
--platform managed \
--allow-unauthenticated \
--project ${{ vars.GOOGLE_PROJECT_ID }} \
--format json
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use uma Imagem Official do Python
FROM python:3

# Definindo o diretório onde a aplicação será armazenada
WORKDIR /app

# Copiar os arquivos da pasta local para dentro do container
COPY . /app

# Instalar as dependências de Python de acordo com o que foi desenvolvido na aplicação e que está declarado no arquivo requirements.txt.
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Garante que será iniciado a aplicação.
CMD ["gunicorn", "app:app"]
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
gunicorn

0 comments on commit 1774337

Please sign in to comment.