Skip to content

Commit

Permalink
Merge pull request #402 from sparcs-kaist/develop
Browse files Browse the repository at this point in the history
Upgrade major version to 3
  • Loading branch information
injoonH committed Aug 2, 2023
2 parents bc03af6 + e33c15f commit 5797c3c
Show file tree
Hide file tree
Showing 96 changed files with 3,016 additions and 4,066 deletions.
20 changes: 14 additions & 6 deletions .docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

set -ex

Expand All @@ -19,12 +19,20 @@ done


if [ "$1" = "test" ]; then
venv/bin/python manage.py compilemessages -l en -l ko
venv/bin/pytest tests --verbose
python3 manage.py compilemessages -l en -l ko
pytest tests --verbose
elif [ "$1" = "dx" ]; then
if [ ! -f .init.lock.log ]; then
python manage.py collectstatic --noinput
python manage.py migrate --no-input
python manage.py compilemessages -l en -l ko
touch .init.lock.log
fi
sleep infinity
else
venv/bin/python manage.py collectstatic --noinput
venv/bin/python manage.py migrate --no-input
venv/bin/python manage.py compilemessages -l en -l ko
python3 manage.py collectstatic --noinput
python3 manage.py migrate --no-input
python3 manage.py compilemessages -l en -l ko
ln -s /newara/www/.docker/supervisor-app.conf /etc/supervisor/conf.d/ || true
exec supervisord -n
fi
4 changes: 2 additions & 2 deletions .docker/supervisor-app.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[program:gunicorn]
command=/newara/www/venv/bin/gunicorn -b 0.0.0.0:9000 -w 3 --timeout 120 ara.wsgi:application
command=gunicorn -b 0.0.0.0:9000 -w 3 --timeout 120 ara.wsgi:application
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:celery-beat]
command=/newara/www/venv/bin/celery -A ara beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
command=celery -A ara beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
directory=/newara/www
stdout_logfile=/var/log/newara/celery-beat.log
stderr_logfile=/var/log/newara/celery-beat.log
2 changes: 1 addition & 1 deletion .docker/supervisor-celery-worker.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:celery-worker]
command = /newara/www/venv/bin/celery -A ara worker -l info
command=celery -A ara worker -l info
directory=/newara/www
stdout_logfile=/var/log/newara/celery-worker.log
stderr_logfile=/var/log/newara/celery-worker.log
17 changes: 6 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Set default charset
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[.env]
insert_final_newline = false

# 4 space indentation
[*.py]
indent_size = 4
indent_style = space
indent_size = 4

[.env]
insert_final_newline = false
12 changes: 6 additions & 6 deletions .github/workflows/generate-docker-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ if [ ! -z $GITHUB_REF ]; then
export PUSH=true
if [ $NAME = "master" ]; then
export DOCKER_TAG=prod
export CACHE_DOCKER_TAG=prod
export DJANGO_ENV=production
echo $FIREBASE_SERVICE_ACCOUNT_KEY_PROD > firebaseServiceAccountKey.json
elif [ $NAME = "develop" ]; then
# Docker tag에 /가 들어갈 수 없어서 -로 변경
export DOCKER_TAG=develop
export CACHE_DOCKER_TAG=develop
export DJANGO_ENV=development
echo $FIREBASE_SERVICE_ACCOUNT_KEY_DEV > firebaseServiceAccountKey.json
else
export DOCKER_TAG=manual
export CACHE_DOCKER_TAG=develop
export DJANGO_ENV=development
export PUSH=true
echo $FIREBASE_SERVICE_ACCOUNT_KEY_DEV > firebaseServiceAccountKey.json
fi
elif [ $TRIGGER_TYPE = "tags" ]; then
export PUSH=true
export DOCKER_TAG=$NAME
export CACHE_DOCKER_TAG=prod
export DJANGO_ENV=production
echo $FIREBASE_SERVICE_ACCOUNT_KEY_PROD > firebaseServiceAccountKey.json

elif [ $TRIGGER_TYPE = "pull" ]; then
export PUSH=true
export DOCKER_TAG="pr$NAME"
export CACHE_DOCKER_TAG=develop
export DJANGO_ENV=development
echo $FIREBASE_SERVICE_ACCOUNT_KEY_DEV > firebaseServiceAccountKey.json

fi
fi

echo $PUSH $TRIGGER_TYPE $CACHE_DOCKER_TAG $DOCKER_TAG
echo $PUSH $TRIGGER_TYPE $DJANGO_ENV $DOCKER_TAG
9 changes: 4 additions & 5 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ env:
jobs:
deploy:
name: Run Tests
# runs-on: ubuntu-20.04
runs-on: [self-hosted]
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand All @@ -49,11 +48,11 @@ jobs:
. .github/workflows/generate-docker-tag.sh
echo "PUSH=$PUSH" >> $GITHUB_ENV
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
echo "CACHE_DOCKER_TAG=$CACHE_DOCKER_TAG" >> $GITHUB_ENV
docker pull $ECR/$PROJECT_NAME:$CACHE_DOCKER_TAG || true
echo "DJANGO_ENV=$DJANGO_ENV" >> $GITHUB_ENV
docker pull $ECR/$PROJECT_NAME:$DJANGO_ENV || true
- name: Build
run: |
docker build --build-arg AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID --build-arg AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY) --cache-from $ECR/$PROJECT_NAME:$CACHE_DOCKER_TAG -t $PROJECT_NAME .
docker build --build-arg AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID --build-arg AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY) --cache-from $ECR/$PROJECT_NAME:$DJANGO_ENV -t $PROJECT_NAME .
- name: Run test
run: |
Expand Down
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ repos:
hooks:
- id: isort
args: [--profile=black]

- repo: https://github.com/python-poetry/poetry
rev: 1.3.1
hooks:
- id: poetry-check
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
FROM python:3.7
FROM python:3.11

RUN pip install --upgrade pip virtualenv awscli
RUN apt update && apt install netcat-openbsd supervisor gettext -y

ENV VIRTUAL_ENV=/newara/www/venv
RUN virtualenv -p python3 $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /newara/www

RUN apt-get update && apt-get install netcat-openbsd supervisor vim gettext -y
COPY Pipfile Pipfile.lock ./

ADD ./ /newara/www
RUN pip install pipenv
RUN pipenv requirements > requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

WORKDIR /newara/www
RUN pip install poetry
RUN poetry config virtualenvs.create false && poetry install
COPY . .

RUN mkdir -p /var/log/newara/
RUN chmod +x /newara/www/.docker/run.sh
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ run:
python manage.py runserver 0.0.0.0:9000

shell:
python manage.py shell -i bpython
python manage.py shell -i ipython

migrate:
python manage.py makemigrations --merge
Expand Down Expand Up @@ -64,3 +64,6 @@ elasticsearch_index:

show_sql:
python manage.py shell_plus --print-sql

schema:
python3 manage.py spectacular --color --file schema.yml
50 changes: 50 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "~=4.2"
djangorestframework = "~=3.14"
python-dotenv = "*"
awscli = "*"
gunicorn = "*"
celery = "*"
django-environ = "*"
firebase-admin = "*"
sentry-sdk = "*"
redis = "*"
django-filter = "*"
django-extensions = "*"
django-s3-storage = "*"
django-celery-beat = "*"
django-celery-results = "*"
drf-spectacular = "*"
django-cacheops = "*"
django-elasticsearch-dsl = "~=7.3"
mysqlclient = "*"
beautifulsoup4 = "*"
bleach = "*"
django-redis = "*"
pillow = "*"
html5lib = "*"
pytest = "*"
pytest-django = "*"
django-cors-headers = "*"
django-debug-toolbar = "*"
django-debug-toolbar-force = "*"
pyyaml = "~=5.3.1"
uritemplate = "*"
tqdm = "*"
lxml = "*"
django-ses = "*"

[dev-packages]
black = "*"
isort = "*"
pre-commit = "*"
ipython = "*"
pytest-cov = "*"

[requires]
python_version = "3.11"
Loading

0 comments on commit 5797c3c

Please sign in to comment.