-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from domino14/python3
Upgrade app to Python 3
- Loading branch information
Showing
89 changed files
with
470 additions
and
762 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
version: 2 | ||
jobs: | ||
build_python: | ||
working_directory: /opt/webolith | ||
environment: | ||
PGSQL_DB_NAME: circle | ||
PGSQL_USER: postgres | ||
PGSQL_HOST: 127.0.0.1 | ||
PGSQL_PASSWORD: | ||
# Debug for tests is False even if I set this to True. | ||
DEBUG: false | ||
DEBUG_JS: false | ||
# Just some random secret key | ||
INTERCOM_APP_SECRET_KEY: abcdefghijklmnopqrstuvwxyz | ||
SECRET_KEY: csw*nc9gznwuz)(w9&u#h_b2dp1%hzf_w#)%yrzwas%+v8ck_q | ||
WORD_DB_LOCATION: /opt/db | ||
REDIS_HOST: localhost | ||
docker: | ||
- image: domino14/webolith-base-pkg:py3-latest | ||
- image: redis:alpine | ||
- image: postgres | ||
steps: | ||
- checkout # Into the webolith-base-pkg | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "ad:9e:01:fa:fa:e7:03:a4:49:74:98:91:52:a8:dc:3c" | ||
- run: | ||
name: Install git and ssh | ||
command: apk update && apk upgrade && apk add git openssh | ||
- run: | ||
name: Install ssl | ||
command: apk add --update ca-certificates openssl && update-ca-certificates | ||
- run: if [ ! -n "$(grep "^bitbucket.org " ~/.ssh/known_hosts)" ]; then ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts 2>/dev/null; fi | ||
- run: | ||
name: Clone word dbs Webolith repo | ||
command: git clone [email protected]:cesar_del_solar/webolith-word-dbs.git /opt/webolith-word-dbs | ||
- run: mkdir $WORD_DB_LOCATION | ||
- run: cd /opt/webolith-word-dbs && tar xzvf dbs.tar.gz | ||
- run: mv /opt/webolith-word-dbs/*.db $WORD_DB_LOCATION | ||
- run: | ||
name: install dockerize | ||
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
environment: | ||
DOCKERIZE_VERSION: v0.6.0 | ||
- run: | ||
name: Wait for db | ||
command: dockerize -wait tcp://localhost:5432 -timeout 1m | ||
- run: | ||
name: Wait for redis | ||
command: dockerize -wait tcp://localhost:6379 -timeout 1m | ||
- run: | ||
name: Install Pylint | ||
command: pip install pylint pylint-django | ||
- run: | ||
name: Pylint | ||
command: pylint --errors-only --load-plugins=pylint_django djAerolith/ | ||
- run: | ||
name: Django tests | ||
command: cd djAerolith && ./manage.py test -v2 | ||
|
||
build_js: | ||
working_directory: /opt/webolith | ||
docker: | ||
- image: node:alpine | ||
steps: | ||
- checkout | ||
- run: npm install -g yarn | ||
- run: yarn install | ||
- run: yarn eslint && yarn jshint && yarn test && yarn prod:build | ||
- run: apk add --update ca-certificates openssl && update-ca-certificates | ||
- persist_to_workspace: | ||
root: djAerolith/static | ||
paths: | ||
- dist | ||
|
||
build_docker: | ||
working_directory: /opt/webolith | ||
environment: | ||
REPO: /opt/webolith | ||
SECRET_KEY: csw*nc9gznwuz)(w9&u#h_b2dp1%hzf_w#)%yrzwas%+v8ck_q | ||
# For collecting static files to later copy into Nginx. This | ||
# dir must be in the context of the build, so inside the kubernetes dir. | ||
STATIC_ROOT: /opt/webolith/kubernetes/webolith_static/ | ||
docker: | ||
- image: domino14/webolith-base-pkg:py3-latest | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- attach_workspace: | ||
at: djAerolith/static | ||
- run: | ||
name: Install curl | ||
command: apk --no-cache add curl | ||
- run: | ||
name: Install Docker client | ||
command: | | ||
set -x | ||
VER="17.12.0-ce" | ||
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz | ||
tar -xz -C /tmp -f /tmp/docker-$VER.tgz | ||
mv /tmp/docker/* /usr/bin | ||
- run: | ||
name: Collect static files | ||
command: cd djAerolith && ./manage.py collectstatic --noinput | ||
- run: | ||
name: Compile messages | ||
command: cd djAerolith && ./manage.py compilemessages | ||
- run: | ||
name: Build and push Docker images to Dockerhub | ||
command: | | ||
cd $REPO/kubernetes && \ | ||
docker build -t domino14/webolith-nginx:$CIRCLE_BUILD_NUM \ | ||
-f nginx-Dockerfile --build-arg static_root=./webolith_static/ . | ||
# Delete the static files for the webapp container. | ||
rm -rf $STATIC_ROOT | ||
cd $REPO && \ | ||
docker build -t domino14/webolith:$CIRCLE_BUILD_NUM \ | ||
-t domino14/webolith:latest . | ||
docker login --username domino14 --password $DOCKER_PASSWORD | ||
docker push domino14/webolith-nginx:$CIRCLE_BUILD_NUM | ||
docker push domino14/webolith:$CIRCLE_BUILD_NUM | ||
docker push domino14/webolith:latest | ||
deploy: | ||
working_directory: /opt/webolith | ||
environment: | ||
# This will get created by the clone below. | ||
KUBECONFIG: /opt/webolith-private/admin.conf | ||
docker: | ||
- image: domino14/aerolith-deployer | ||
steps: | ||
- checkout | ||
# Clone the repo with the admin.conf file | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "ad:9e:01:fa:fa:e7:03:a4:49:74:98:91:52:a8:dc:3c" | ||
- run: if [ ! -n "$(grep "^bitbucket.org " ~/.ssh/known_hosts)" ]; then ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts 2>/dev/null; fi | ||
- run: | ||
name: Clone private Webolith repo | ||
command: git clone [email protected]:cesar_del_solar/webolith-private.git /opt/webolith-private | ||
- run: fab create_k8s_configs:prod | ||
- run: fab deploy:prod | ||
|
||
workflows: | ||
version: 2 | ||
build_app: | ||
jobs: | ||
- build_python | ||
- build_js | ||
- build_docker: | ||
requires: | ||
- build_python | ||
- build_js | ||
filters: | ||
branches: | ||
only: master | ||
- deploy: | ||
requires: | ||
- build_docker | ||
filters: | ||
branches: | ||
only: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ words/* | |
node/* | ||
.git/* | ||
**/*.pyc | ||
**/__pycache__ | ||
config/*.env | ||
node_modules/* | ||
kubernetes/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ kubernetes/deploy-configs/prod-*.yaml | |
djAerolith/htmlcov | ||
vars.sh | ||
coverage | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[MASTER] | ||
init-hook='base_dir="djAerolith"; import sys,os,re; _re=re.search(r".+\/" + base_dir, os.getcwd()); project_dir = _re.group() if _re else os.path.join(os.getcwd(), base_dir); sys.path.append(project_dir)' | ||
|
||
[MESSAGES CONTROL] | ||
# Find available symbolic names in: | ||
# https://docs.pylint.org/features.html | ||
disable=missing-docstring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"python.linting.flake8Enabled": false, | ||
"python.pythonPath": "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3", | ||
"python.linting.pylintArgs": [ | ||
"--load-plugins=pylint_django" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
FROM domino14/webolith-base-pkg | ||
FROM domino14/webolith-base-pkg:py3-latest | ||
MAINTAINER Cesar Del Solar <[email protected]> | ||
|
||
COPY . /opt/webolith/ | ||
WORKDIR /opt/webolith/djAerolith | ||
|
||
EXPOSE 8000 | ||
# Run command in exec form because /bin/sh does not pass signals to its children. | ||
CMD ["daphne", "-b", "0.0.0.0", "asgi:channel_layer"] | ||
CMD ["daphne", "-b", "0.0.0.0", "djaerolith.asgi:channel_layer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Base image that we can base the prod image on. | ||
|
||
FROM python:2-alpine | ||
FROM python:3-alpine | ||
MAINTAINER Cesar Del Solar <[email protected]> | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
@@ -11,4 +11,4 @@ COPY djAerolith/prod_requirements.txt /opt/prod_requirements.txt | |
RUN pip install --upgrade pip | ||
RUN pip install -r /opt/prod_requirements.txt | ||
|
||
# Prod image can import this image, and build on top of it. | ||
# Prod image can import this image, and build on top of it. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
djAerolith/accounts/migrations/0002_remove_aerolithprofile_wordwallsmedals.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
|
||
from django.db import migrations, models | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.