Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
3,113 additions
and
1,885 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,24 @@ | ||
onCreate: | ||
- sudo apt-get update -y | ||
- sudo apt install python-is-python3 xvfb libfontconfig wkhtmltopdf libpq-dev python3-dev python3-pip build-essential libssl-dev libffi-dev python3-venv redis-server redis-tools virtualenv zsh python3-virtualenv -y | ||
- sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | ||
- pip install virtualenvwrapper | ||
- echo "source /home/ubuntu/.local/bin/virtualenvwrapper.sh" >> ~/.zshrc && source ~/.zshrc | ||
- | | ||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | ||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | ||
sudo apt-get update | ||
sudo apt-get -y install postgresql | ||
- | | ||
sudo -u postgres psql postgres -c "ALTER USER postgres PASSWORD 'root'" | ||
sudo -u postgres psql postgres -c "CREATE DATABASE bottlecrm WITH OWNER = postgres" | ||
- | | ||
mkvirtualenv bottlecrm | ||
cp ENV.md .env | ||
pip install -U pip | ||
pip install -r requirements.txt | ||
python manage.py migrate | ||
onStart: | ||
- | | ||
workon bottlecrm | ||
python manage.py runserver |
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,21 +1,40 @@ | ||
FROM python:3.6 | ||
FROM ubuntu:20.04 | ||
|
||
WORKDIR /app | ||
ARG APP_NAME | ||
|
||
# Intall dependencies | ||
COPY requirements.txt /app/ | ||
# test arg | ||
RUN test -n "$APP_NAME" | ||
|
||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ | ||
apt update && \ | ||
apt install -y git ruby-dev nodejs postgresql-client redis-server wkhtmltopdf && \ | ||
apt clean && \ | ||
gem install compass sass && \ | ||
npm -g install less && \ | ||
pip install --no-cache-dir -r requirements.txt && \ | ||
pip install --no-cache-dir redis | ||
# install system packages | ||
RUN apt-get update -y | ||
RUN apt-get install -y \ | ||
python3-pip \ | ||
python3-venv \ | ||
build-essential \ | ||
libpq-dev \ | ||
libmariadbclient-dev \ | ||
libjpeg62-dev \ | ||
zlib1g-dev \ | ||
libwebp-dev \ | ||
curl \ | ||
vim \ | ||
net-tools | ||
|
||
COPY . /app/ | ||
# setup user | ||
RUN useradd -ms /bin/bash ubuntu | ||
USER ubuntu | ||
|
||
RUN chmod +x /app/entrypoint.sh \ | ||
/app/wait-for-postgres.sh | ||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
# install app | ||
RUN mkdir -p /home/ubuntu/"$APP_NAME"/"$APP_NAME" | ||
WORKDIR /home/ubuntu/"$APP_NAME"/"$APP_NAME" | ||
COPY . . | ||
RUN python3 -m venv ../venv | ||
RUN . ../venv/bin/activate | ||
RUN /home/ubuntu/"$APP_NAME"/venv/bin/pip install -U pip | ||
RUN /home/ubuntu/"$APP_NAME"/venv/bin/pip install -r requirements.txt | ||
RUN /home/ubuntu/"$APP_NAME"/venv/bin/pip install gunicorn | ||
|
||
# setup path | ||
ENV PATH="${PATH}:/home/ubuntu/$APP_NAME/$APP_NAME/scripts" | ||
|
||
USER ubuntu |
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,38 @@ | ||
# Environment variables | ||
|
||
SECRET_KEY="" | ||
ENV_TYPE="dev" | ||
DOMAIN_NAME="" | ||
|
||
# AWS | ||
AWS_BUCKET_NAME="" | ||
|
||
AWS_ACCESS_KEY_ID="" | ||
AWS_SECRET_ACCESS_KEY="" | ||
AWS_SES_REGION_NAME="" | ||
AWS_SES_REGION_ENDPOINT="" | ||
|
||
|
||
# DB | ||
DBNAME="bottlecrm" | ||
DBUSER="postgres" | ||
DBPASSWORD="root" | ||
DBHOST="localhost" | ||
DBPORT="" | ||
|
||
# Sentry | ||
SENTRY_DSN="" | ||
|
||
# Celery | ||
CELERY_BROKER_URL="" | ||
CELERY_RESULT_BACKEND="" | ||
|
||
# Swagger | ||
SWAGGER_ROOT_URL="" | ||
|
||
#CACHES | ||
MEMCACHELOCATION="" | ||
|
||
DEFAULT_FROM_EMAIL="" | ||
ADMIN_EMAIL="" |
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,62 @@ | ||
pipeline { | ||
agent any | ||
|
||
environment { | ||
ENV_TYPE = "dev" | ||
APP_NAME = "bottlecrm-api" | ||
DOCKERHUB = credentials("dockerhub") | ||
DOCKER_IMAGE_TAG = "build-${env.BUILD_NUMBER}-${env.GIT_COMMIT[0..7]}" | ||
DOCKER_IMAGE = "ashwin31/bottlecrm-api:${env.DOCKER_IMAGE_TAG}" | ||
DOCKER_CONFIG = "config.json" | ||
} | ||
|
||
stages { | ||
stage("build") { | ||
steps { | ||
sh "pwd; whoami; ls -al;" | ||
sh "docker build --build-arg APP_NAME=$APP_NAME -t ${env.DOCKER_IMAGE} ." | ||
} | ||
} | ||
|
||
stage("push") { | ||
steps { | ||
sh "echo '$DOCKERHUB_PSW' | docker login -u $DOCKERHUB_USR --password-stdin" | ||
sh "docker push ${env.DOCKER_IMAGE}" | ||
} | ||
} | ||
stage('trigger deploy') { | ||
steps { | ||
build job: 'bottlecrm-api-deploy', parameters: [ | ||
string( | ||
name: 'ENV_TYPE', | ||
value: "${env.ENV_TYPE}" | ||
), | ||
string( | ||
name: 'APP_NAME', | ||
value: "${env.APP_NAME}" | ||
), | ||
string( | ||
name: 'DOCKER_IMAGE', | ||
value: "${env.DOCKER_IMAGE}" | ||
) | ||
] | ||
} | ||
} | ||
} | ||
|
||
post { | ||
always { | ||
cleanWs() | ||
dir("${env.WORKSPACE}@tmp") { | ||
deleteDir() | ||
} | ||
dir("${env.WORKSPACE}@script") { | ||
deleteDir() | ||
} | ||
dir("${env.WORKSPACE}@script@tmp") { | ||
deleteDir() | ||
} | ||
sh 'docker rmi $(docker images -aq) || true' | ||
} | ||
} | ||
} |
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
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
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
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
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.