Skip to content

Commit

Permalink
Merge pull request #222 from code4romania/develop
Browse files Browse the repository at this point in the history
Prod push
  • Loading branch information
tudoramariei authored Jan 30, 2024
2 parents 8b355b0 + 2425aea commit 686a6c0
Show file tree
Hide file tree
Showing 61 changed files with 1,395 additions and 762 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=catpol

DATABASE_URL=postgres://postgres:postgres@db/catpol
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# they will be requested for review when someone
# opens a pull request.
* @catileptic

# More details on creating a codeowners file:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
23 changes: 23 additions & 0 deletions .github/workflows/build_push_dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build and push to Dockerhub
on: [push, pull_request]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Build the Docker image
if: github.ref == 'refs/heads/develop'
run: |
docker build . \
--file ./Dockerfile \
--tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:latest
- name: Login to docker registry
if: github.ref == 'refs/heads/develop'
run: docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Push to docker registry
if: github.ref == 'refs/heads/develop'
run: docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:latest
19 changes: 0 additions & 19 deletions .github/workflows/hello_world.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
pull_request:
branches:
- develop

jobs:
tests:
runs-on: ubuntu-latest
container: alexstefanescu/catpol-dependencies

steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Check formatting with black
run: |
black --line-length 120 --target-version py37 --check .
- name: Run tests
env:
DJANGO_SETTINGS_MODULE: project_template.settings.dev
run: pytest project_template
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
FROM alexstefanescu/catpol-dependencies

RUN pip3 install --upgrade pip setuptools
RUN pip3 install --upgrade pip setuptools \
&& wget -qO- https://github.com/jwilder/dockerize/releases/download/v0.2.0/dockerize-linux-amd64-v0.2.0.tar.gz | tar -zxf - -C /usr/bin \
&& chown root:root /usr/bin/dockerize

ARG ENVIRONMENT=dev
ENV DJANGO_SETTINGS_MODULE=project_template.settings.${ENVIRONMENT}

# RUN find -type d -name __pycache__ -prune -exec rm -rf {} \; && \
# rm -rf ~/.cache/pip
COPY ./ /opt/catpol

# Re-install dependencies since it might have updated from cache
RUN pip3 install -r requirements-${ENVIRONMENT}.txt

COPY . /opt/catpol
RUN python3 manage.py check
CMD python3 manage.py migrate --run-syncdb \
&& python3 manage.py runserver 0.0.0.0:8000

ENTRYPOINT ["/opt/catpol/docker-entrypoint"]
EXPOSE 8000
57 changes: 24 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Catalog politic - Declaratii de avere [![GitHub contributors](https://img.shields.io/github/contributors/code4romania/catpol-declaratii.svg)](https://github.com/code4romania/catpol-declaratii/graphs/contributors) [![GitHub last commit](https://img.shields.io/github/last-commit/code4romania/catpol-declaratii.svg)](https://github.com/code4romania/catpol-declaratii/commits/master) [![License: MPL 2.0](https://img.shields.io/badge/license-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
# Catalog politic - Declaratii de avere
[![GitHub contributors](https://img.shields.io/github/contributors/code4romania/asset-declarations.svg)](https://github.com/code4romania/asset-declarations/graphs/contributors) [![GitHub last commit](https://img.shields.io/github/last-commit/code4romania/asset-declarations.svg)](https://github.com/code4romania/asset-declarations/commits/master) [![License: MPL 2.0](https://img.shields.io/badge/license-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)

<!-- Please don't remove this: Grab your social icons from https://github.com/carlsednaoui/gitsocial -->

Expand All @@ -20,10 +21,7 @@

<!-- Please don't remove this: Grab your social icons from https://github.com/carlsednaoui/gitsocial -->

* MAKING PUBLIC INFORMATION TRULY PUBLIC
* data from asset declarations, including a net worth estimation

**Important!** This project is currently out of sync with the latest version of [Moonsheep](https://github.com/themoonsheep/moonsheep), a library that it is dependent on. In order for development to continue, we must first fix [this critical issue](https://github.com/code4romania/catpol-declaratii/issues/191).
**Important!** This project is currently not accepting contributions. It would seem like there is a public-sector effort to solve the problem of opening up the data contained within asset declarations. We will not duplicate effort and we will either resume or archive this project according to what we learn about the digitalisation effort.

Currently, in Romania, public information on elected officials is spread on a multitude of media, in a multitude of formats and requires a
priori knowledge of the sources where data resides, making it hard, if not impossible for a regular citizen to make sense of the data.
Expand All @@ -45,16 +43,23 @@ Catalog Politic - Declaratii de avere - aims to automate the process of parsing

[Built with](#built-with) | [Repos and projects](#repos-and-projects) | [Deployment](#deployment) | [Contributing](#contributing) | [Feedback](#feedback) | [License](#license) | [About Code4Ro](#about-code4ro)

## Built With
## Built With

[Django](https://www.djangoproject.com)
[Moonsheep](http://moonsheep.org/)
[Django](https://www.djangoproject.com)
[Moonsheep](http://moonsheep.org/)

### Programming languages

Python 3.5+
Python 3.5+
Please follow [the Python style guide](python_style_guide.md).

In order to solve the formatting debates, [black](https://github.com/psf/black) is enforced.
Before submiting a PR, you can run
```bash
black --line-length 80 --target-version py37 .
```
and your code will be automatically formatted.

### Platforms

Political Catalogue - Asset Declaration is a web application.
Expand All @@ -69,46 +74,32 @@ Political Catalogue - Asset Declaration is a web application.

### Database technology & provider

This remains currently undecided.
[PostgreSQL](https://www.postgresql.org/)

## Repos and projects

[Moonsheep on GitHub](https://github.com/themoonsheep)
[PyBossa on GitHub](https://github.com/Scifabric/pybossa)
[Moonsheep on GitHub](https://github.com/themoonsheep)

## Deployment
## Deployment

Installation process
* Fork this repo
* Clone your fork
* Open the directory where you have cloned the repo (`cd catpol-declaratii`)
* Open the directory where you have cloned the repo (`cd asset-declarations`)
* Optionally, you can create a virtual environment named "venv": `python3 -m venv venv` and then activate it: `source venv/bin/activate`
* `pip install -r requirements-dev.txt`
* `export DJANGO_SETTINGS_MODULE=project_template.settings.dev`
* `python manage.py migrate --run-syncdb`
* `python manage.py seed`
* `python manage.py runserver`

Using Dockerfile:
* Install docker
Using docker-compose:
* Install docker and cdocker-compose
* Fork this repo
* Clone your fork
* Open the directory where you have cloned the repo (`cd catpol-declaratii`)
* Run the following command to create a Docker image for the project `docker build -t catpol`
* Run the following command to run the Docker image `docker run -p 8000 catpol`
* Show the container id running the `catpol` image `docker ps`
* Inspect the container to get the host port `docker inspect <container_id>`, you should see something like:
```json
"Ports": {
"8000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "32769"
}
]
},
```
* Connect to specified port on localhost and enjoy the solution

* Open the directory where you have cloned the repo (`cd asset-declarations`)
* Run the following command to start the development server `docker-compose up`
* You can interact with the container's environment using `docker-compose exec web bash`

## Contributing

Expand Down
8 changes: 3 additions & 5 deletions catpol-dependencies/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ RUN apk update && \
gcc python-dev musl-dev \
postgresql-dev git \
build-base python3-dev openblas-dev \
freetype-dev pkgconfig gfortran \
freetype-dev pkgconfig gfortran gettext \
bash

RUN pip3 install --upgrade pip setuptools

ARG ENVIRONMENT=dev

WORKDIR /opt/catpol
COPY ./requirements* /opt/catpol/
RUN pip3 install -r requirements-${ENVIRONMENT}.txt

# RUN find -type d -name __pycache__ -prune -exec rm -rf {} \; && \
# rm -rf ~/.cache/pip
COPY ./requirements* /opt/catpol/
RUN pip3 install -r requirements-${ENVIRONMENT}.txt
3 changes: 0 additions & 3 deletions database.env

This file was deleted.

22 changes: 12 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
version: '3'
services:
catpol-database:
web:
build: .
command: dockerize -wait tcp://db:5432 -timeout 90s
ports:
- "8000:8000"
volumes:
- ./:/opt/catpol

db:
image: "postgres:12"
container_name: catpol_psql
ports:
- "5432:5432"
env_file:
- database.env
- .env
volumes:
- database-data:/var/lib/postgresql/data/
catpol:
build: .
container_name: catpol
ports:
- "8000:8000"
- database-data:/var/lib/postgresql/data/

volumes:
database-data:
database-data:
12 changes: 12 additions & 0 deletions docker-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

PORT=${PORT:-"8000"}

echo "Migrating databse"
python3 manage.py migrate --run-syncdb

echo "Seed"
python3 manage.py seed

echo "Start web server on $PORT"
python3 manage.py runserver "0.0.0.0:$PORT"
Binary file modified locale/en/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 686a6c0

Please sign in to comment.