Skip to content

Commit

Permalink
Merge pull request #1313 from goat-community/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
EPajares authored May 2, 2022
2 parents 225ff91 + 4a618be commit 7270495
Show file tree
Hide file tree
Showing 383 changed files with 11,737 additions and 21,591 deletions.
67 changes: 33 additions & 34 deletions .env_template
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,57 @@
# The settings are suited for development purpose. #
# If you're deploying GOAT for production, you need to #
# consider using k8s config files #
# #
# DO NOT FORGET to also modify values in _secrets ! #
# # #
# #
##############################################################

#### Global Settings
# GLOBAL SETTINGS
COMPOSE_PROJECT_NAME=goat
PROJECT_VERSION=1.2
DOCKER_ID=goatcommunity
DOMAIN_NAME=localhost

#### Database Settings
# Database environment
POSTGRES_USER=goat
# PostgreSQL superuser password (to be set if PostgreSQL is exposed)
POSTGRES_PASSWORD=postgres
# The outer port for remote connections (The port should be unique)
# DATABASE ENV
POSTGRES_SERVER=goat_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=12345678
POSTGRES_OUTER_PORT=55432

# Flower
FLOWER_BASIC_AUTH=admin:Berat_123

# PgAdmin
PGADMIN_LISTEN_PORT=5050
PGADMIN_DEFAULT_EMAIL=majk.shkurti@plan4better.de
PGADMIN_DEFAULT_EMAIL=pgadmin@plan4better.de
PGADMIN_DEFAULT_PASSWORD=Tirana_123

# API
BACKEND_CORS_ORIGINS=["http://localhost","http://localhost:5000","http://localhost:8001", "http://localhost:8002", "http://localhost:8003", "http://localhost:8004", "http://localhost:4200", "http://localhost:3000", "http://localhost:8080", "https://localhost", "https://localhost:4200", "https://localhost:3000", "https://localhost:8080", "http://dev.goat-api.com", "https://stag.goat-api.com", "https://goat-api.com"]
API_SECRET_KEY=Berat_123
FIRST_SUPERUSER_PASSWORD=StrongPassword
# DATABASE STAGING ENV
POSTGRES_DB_STAGING=goat_update
POSTGRES_SERVER_STAGING=db
POSTGRES_USER_STAGING=postgres
POSTGRES_PASSWORD_STAGING=12345678
POSTGRES_OUTER_PORT_STAGING=5432

# API ENV
BACKEND_CORS_ORIGINS=["http://localhost"]
API_SECRET_KEY=12345678
FIRST_ORGANIZATION=Plan4Better
FIRST_SUPERUSER_NAME=FirstUserName
FIRST_SUPERUSER_SURNAME=FirstUserSurname
FIRST_SUPERUSER_PASSWORD=12345678
[email protected]
FIRST_SUPERUSER_STORAGE=500000 #In kilobytes
FIRST_SUPERUSER_ACTIVE_STUDY_AREA_ID=91620000
SMTP_TLS=True
SMTP_PORT=587
SMTP_HOST=
SMTP_USER=
SMTP_PASSWORD=
EMAILS_FROM_EMAIL=support@plan4better.de
EMAILS_FROM_EMAIL=test-reply@plan4better.de
USERS_OPEN_REGISTRATION=False
SENTRY_DSN=https://[email protected]/5906096
SENTRY_DSN=
INSTALL_DEV=True
INSTALL_JUPYTER=True

#### Staging Database Setting
#### Staging Database Setting
STAGING=False
# Database user
STAGING_POSTGRES_USER=goat
# Database name
STAGING_POSTGRES_DB=goat
# Host
STAGING_POSTGRES_HOST="172.17.0.1"
# PostgreSQL superuser password (to be set if PostgreSQL is exposed)
STAGING_POSTGRES_PASSWORD=earlmanigault
# The outer port for remote connections (The port should be unique)
STAGING_POSTGRES_OUTER_PORT=65432
# FRONTENDENV
VUE_APP_I18N_LOCALE=en
VUE_APP_I18N_FALLBACK_LOCALE=en
VUE_APP_SEARCH_KEY=ca068d7840bca4
VUE_APP_SEARCH_URL=https://api.locationiq.com/v1
API_BASEURL=http://goat_api:5000/
FONTAWESOME_NPM_AUTH_TOKEN=
10 changes: 9 additions & 1 deletion .github/workflows/Push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
name: ${{ needs.release.outputs.env_name }}
needs: [release]
env:


AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
Expand All @@ -57,8 +59,14 @@ jobs:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
API_SECRET_KEY: ${{ secrets.API_SECRET_KEY }}
FIRST_SUPERUSER_PASSWORD: ${{ secrets.FIRST_SUPERUSER_PASSWORD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
EMAILS_FROM_EMAIL: ${{ secrets.EMAILS_FROM_EMAIL }}
FIRST_ORGANIZATION: ${{ secrets.FIRST_ORGANIZATION }}
FIRST_SUPERUSER_EMAIL: ${{ secrets.FIRST_SUPERUSER_EMAIL }}
FIRST_SUPERUSER_PASSWORD: ${{ secrets.FIRST_SUPERUSER_PASSWORD }}
FIRST_SUPERUSER_NAME: ${{ secrets.FIRST_SUPERUSER_NAME }}
FIRST_SUPERUSER_SURNAME: ${{ secrets.FIRST_SUPERUSER_SURNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Get changed files
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ K8S_OBJ:=$(patsubst %.tpl.yaml,%.yaml,$(K8S_SRC))
POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) \
API_SECRET_KEY=$(API_SECRET_KEY) \
SENTRY_DSN=$(SENTRY_DSN) \
EMAILS_FROM_EMAIL=$(EMAILS_FROM_EMAIL) \
FIRST_SUPERUSER_EMAIL=$(FIRST_SUPERUSER_EMAIL) \
FIRST_SUPERUSER_PASSWORD=$(FIRST_SUPERUSER_PASSWORD) \
FIRST_ORGANIZATION=$(FIRST_ORGANIZATION) \
FIRST_SUPERUSER_NAME=$(FIRST_SUPERUSER_NAME) \
FIRST_SUPERUSER_SURNAME=$(FIRST_SUPERUSER_SURNAME) \
SMTP_PASSWORD=$(SMTP_PASSWORD) \
t=$$(cat $<); eval "echo \"$${t}\"" > $@

# target: make help - displays this help.
Expand Down
Binary file added app/api/.coverage
Binary file not shown.
27 changes: 26 additions & 1 deletion app/api/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,27 @@
],
"jinja": true
},
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
},
{
"name": "g++ - Build and debug active file",
Expand All @@ -45,6 +60,16 @@
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false,
"env": {
"PYTEST_ADDOPTS": "--no-cov"
}
}
]
}
22 changes: 18 additions & 4 deletions app/api/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
"editor.formatOnSave": true,
"peacock.remoteColor": "#1857a4",
"python.formatting.provider": "black",
"python.formatting.blackArgs": ["--line-length=99"],
"python.sortImports.args": ["--profile", "black"],
"python.formatting.blackArgs": [
"--line-length=99"
],
"python.sortImports.args": [
"--profile",
"black"
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
Expand Down Expand Up @@ -86,7 +91,16 @@
"map": "cpp",
"regex": "cpp"
},
"python.testing.pytestArgs": ["app"],
"python.testing.pytestArgs": [
"--cov",
".",
"--cov-report",
"html",
"--cov-report",
"term",
"--cov-report",
"xml"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
}
9 changes: 5 additions & 4 deletions app/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ FROM python:3.9.10
RUN mkdir -p /app
WORKDIR /app/
# Create the app user
RUN addgroup --system app && adduser --system --group app
#RUN addgroup --system app && adduser --system --group app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV ENVIRONMENT prod
ENV PYTHONPATH "${PYTHONPATH}:."
# Install system dependencies
RUN apt-get update \
&& apt-get -y install netcat gcc libpq-dev \
Expand All @@ -30,8 +31,8 @@ ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'True' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
COPY . /app
# chown all the files to the app user
RUN chown -R app:app /app
#RUN chown -R app:app /app
# change to the app user
USER app
#USER app
# run gunicorn
CMD gunicorn --bind 0.0.0.0:5000 src.main:app -k uvicorn.workers.UvicornWorker
CMD gunicorn --bind 0.0.0.0:5000 src.main:app -k uvicorn.workers.UvicornWorker
8 changes: 7 additions & 1 deletion app/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,10 @@ PGAdmin: http://localhost.tiangolo.com:5050

Flower: http://localhost.tiangolo.com:5555

Traefik UI: http://localhost.tiangolo.com:8090
Traefik UI: http://localhost.tiangolo.com:8090

### Dump empty table schema using pgDump

To create an empty data dump used for the data preparation the following command can be executed.

`pg_dump -d db-name -U user-name -h host-name -s -n basic -n customer -x > dump_schema.sql`
31 changes: 31 additions & 0 deletions app/api/alembic/versions/16aa38de4035_added_type_for_poi_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""added type fpr poi config
Revision ID: 16aa38de4035
Revises: fa649dc2dca0
Create Date: 2022-04-22 09:23:23.296973
"""
from alembic import op
import sqlalchemy as sa
import geoalchemy2
import sqlmodel



# revision identifiers, used by Alembic.
revision = '16aa38de4035'
down_revision = 'fa649dc2dca0'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('poi_group', sa.Column('type', sa.Text(), nullable=False), schema='basic')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('poi_group', 'type', schema='basic')
# ### end Alembic commands ###
41 changes: 41 additions & 0 deletions app/api/alembic/versions/1c1cd1e80930_fixed_typo_in_column_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""fixed typo in column name
Revision ID: 1c1cd1e80930
Revises: 9a71c3d6d26c
Create Date: 2022-04-24 12:44:27.069032
"""
from alembic import op
import sqlalchemy as sa
import geoalchemy2
import sqlmodel



# revision identifiers, used by Alembic.
revision = '1c1cd1e80930'
down_revision = '9a71c3d6d26c'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('opportunity_default_config', sa.Column('multiple_entrance', sa.Boolean(), nullable=True), schema='basic')
op.drop_column('opportunity_default_config', 'multiple_entrace', schema='basic')
op.add_column('opportunity_study_area_config', sa.Column('multiple_entrance', sa.Boolean(), nullable=True), schema='basic')
op.drop_column('opportunity_study_area_config', 'multiple_entrace', schema='basic')
op.add_column('opportunity_user_config', sa.Column('multiple_entrance', sa.Boolean(), nullable=True), schema='customer')
op.drop_column('opportunity_user_config', 'multiple_entrace', schema='customer')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('opportunity_user_config', sa.Column('multiple_entrace', sa.BOOLEAN(), autoincrement=False, nullable=True), schema='customer')
op.drop_column('opportunity_user_config', 'multiple_entrance', schema='customer')
op.add_column('opportunity_study_area_config', sa.Column('multiple_entrace', sa.BOOLEAN(), autoincrement=False, nullable=True), schema='basic')
op.drop_column('opportunity_study_area_config', 'multiple_entrance', schema='basic')
op.add_column('opportunity_default_config', sa.Column('multiple_entrace', sa.BOOLEAN(), autoincrement=False, nullable=True), schema='basic')
op.drop_column('opportunity_default_config', 'multiple_entrance', schema='basic')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""added constraints to config
Revision ID: 34ab3518ff84
Revises: 959eb6413158
Create Date: 2022-04-24 08:28:19.462765
"""
from alembic import op
import sqlalchemy as sa
import geoalchemy2
import sqlmodel



# revision identifiers, used by Alembic.
revision = '34ab3518ff84'
down_revision = '959eb6413158'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(None, 'opportunity_default_config', ['category'], schema='basic')
op.drop_constraint('opportunity_default_config_group_fkey', 'opportunity_default_config', schema='basic', type_='foreignkey')
op.create_unique_constraint(None, 'opportunity_study_area_config', ['category', 'study_area_id'], schema='basic')
op.drop_constraint('opportunity_study_area_config_group_fkey', 'opportunity_study_area_config', schema='basic', type_='foreignkey')
op.create_unique_constraint(None, 'opportunity_user_config', ['category', 'study_area_id', 'user_id'], schema='customer')
op.drop_constraint('opportunity_user_config_group_fkey', 'opportunity_user_config', schema='customer', type_='foreignkey')
op.drop_constraint('opportunity_user_config_data_upload_id_fkey', 'opportunity_user_config', schema='customer', type_='foreignkey')
op.drop_constraint('opportunity_user_config_user_id_fkey', 'opportunity_user_config', schema='customer', type_='foreignkey')
op.create_foreign_key(None, 'opportunity_user_config', 'user', ['user_id'], ['id'], source_schema='customer', referent_schema='customer', ondelete='CASCADE')
op.create_foreign_key(None, 'opportunity_user_config', 'data_upload', ['data_upload_id'], ['id'], source_schema='customer', referent_schema='customer', ondelete='CASCADE')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'opportunity_user_config', schema='customer', type_='foreignkey')
op.drop_constraint(None, 'opportunity_user_config', schema='customer', type_='foreignkey')
op.create_foreign_key('opportunity_user_config_user_id_fkey', 'opportunity_user_config', 'user', ['user_id'], ['id'], source_schema='customer', referent_schema='customer')
op.create_foreign_key('opportunity_user_config_data_upload_id_fkey', 'opportunity_user_config', 'data_upload', ['data_upload_id'], ['id'], source_schema='customer', referent_schema='customer')
op.create_foreign_key('opportunity_user_config_group_fkey', 'opportunity_user_config', 'opportunity_group', ['group'], ['group'], source_schema='customer', referent_schema='basic')
op.drop_constraint(None, 'opportunity_user_config', schema='customer', type_='unique')
op.create_foreign_key('opportunity_study_area_config_group_fkey', 'opportunity_study_area_config', 'opportunity_group', ['group'], ['group'], source_schema='basic', referent_schema='basic')
op.drop_constraint(None, 'opportunity_study_area_config', schema='basic', type_='unique')
op.create_foreign_key('opportunity_default_config_group_fkey', 'opportunity_default_config', 'opportunity_group', ['group'], ['group'], source_schema='basic', referent_schema='basic')
op.drop_constraint(None, 'opportunity_default_config', schema='basic', type_='unique')
# ### end Alembic commands ###
Loading

0 comments on commit 7270495

Please sign in to comment.