Skip to content

Commit

Permalink
Workflow for build and push docker images (#8)
Browse files Browse the repository at this point in the history
* Create push_docker_images.yml

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image

* test push image
  • Loading branch information
glaubervila authored Apr 20, 2022
1 parent 29fa2e3 commit b37fe7e
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 8 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/push_docker_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and Push Docker Images

on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'

jobs:

build_backend:
name: Build and Push Backend
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: linea/pzserver
tags: |
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/v') }},priority=100,prefix=backend_,value=latest
type=semver,enable=true,priority=200,prefix=backend_v,suffix=,pattern={{version}}
type=sha,enable=true,priority=300,prefix=backend_,suffix=,format=short
flavor: |
latest=false
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./backend
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build_frontend:
name: Build and Push Frontend
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: linea/pzserver
tags: |
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/v') }},priority=100,prefix=frontend_,value=latest
type=semver,enable=true,priority=200,prefix=frontend_v,suffix=,pattern={{version}}
type=sha,enable=true,priority=300,prefix=frontend_,suffix=,format=short
flavor: |
latest=false
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./frontend
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

14 changes: 7 additions & 7 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# TODO: Instalar as dependencias do LDAP e do Shibboleth.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
build-essential \
libpcre3 \
libpcre3-dev
# RUN apt-get update && \
# apt-get install -y --no-install-recommends \
# gcc \
# python3-dev \
# build-essential \
# libpcre3 \
# libpcre3-dev

RUN python -m venv /opt/venv

Expand Down
1 change: 0 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ djangorestframework==3.13.1
psycopg2-binary==2.9.3
django-cors-headers==3.11.0
django-filebrowser-no-grappelli==4.0.1
uWSGI==2.0.20
gunicorn==20.1.0

0 comments on commit b37fe7e

Please sign in to comment.