Skip to content

Commit

Permalink
Migrate profile and favorites data from mongodb to postgresql (#18)
Browse files Browse the repository at this point in the history
Migrate profile and favorites data from mongodb to postgresql
  • Loading branch information
ysavary committed Jun 24, 2022
1 parent 84df5e6 commit 07caa26
Show file tree
Hide file tree
Showing 31 changed files with 865 additions and 382 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-deploy-production-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and deploy a production docker image based on main branch

on:
push:
tags:
- 'v*.*.*'

jobs:
build-deploy-production-docker:
name: Build and deploy
environment: production
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/winds-mobi/winds-mobi-admin
tags: |
type=semver,pattern={{version}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Update Watchtower containers
run: |
curl -H "Authorization: Bearer ${{ secrets.WATCHTOWER_HTTP_API_TOKEN }}" https://watchtower.winds.mobi/v1/update
35 changes: 35 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test project

on:
push:
branches:
- main
pull_request:

jobs:
test-python:
name: Lint and test
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.9"
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install python dependencies with poetry
run: |
pip install poetry
poetry install
- name: Run python linters
run: |
poetry run black --check .
poetry run flake8 .
- name: Run python tests
run: poetry run pytest
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.9-slim-bullseye AS base
FROM python:3.9.13-slim-bullseye AS base

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
Expand Down
1 change: 1 addition & 0 deletions docker-cmd.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh

python manage.py migrate
gunicorn --workers=3 --bind="0.0.0.0:$PORT" winds_mobi_admin.wsgi
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ version: '3.9'

services:
postgres:
image: postgres:14.1
image: postgres:14.4
ports:
- "5432:5432"
- "8016:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=winds
volumes:
- ./volumes/postgres:/var/lib/postgresql/data

redis:
image: redis:7.0.2
ports:
- "8017:6379"

admin:
build:
context: .
Expand All @@ -27,6 +32,7 @@ services:
ALLOWED_HOSTS: localhost
STATIC_URL: ${STATIC_URL}
DB_URL: ${DB_URL}
REDIS_URL: ${REDIS_URL}
MONGODB_URL: ${MONGODB_URL}
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
FACEBOOK_REDIRECT_URI: ${FACEBOOK_REDIRECT_URI}
Expand Down
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'winds_mobi_admin.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "winds_mobi_admin.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand All @@ -17,5 +17,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit 07caa26

Please sign in to comment.