Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prometheus WIP #5

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
34b351b
attempt initial prometheus
May 27, 2019
88e85b9
include the testing config for prometheus with the db hookup
May 27, 2019
b7bfcd4
locally use sqlite3 instead of postgres
May 27, 2019
4aa5c74
revert change from dev to main
May 27, 2019
080c9aa
attempt initial prometheus
May 27, 2019
024e6b7
Formatting
AllenAnthes Jun 3, 2019
ade529e
Merge remote-tracking branch 'origin/feature/prometheus/master' into …
AllenAnthes Jun 3, 2019
8c287a0
More formatting
AllenAnthes Jun 3, 2019
e5c4ec2
Merge branch 'master' into feature/prometheus/master
AllenAnthes Jun 10, 2019
4946019
Pull in updates from master
AllenAnthes Jun 10, 2019
e04db92
Set DB_ENGINE in prod/staging environments
AllenAnthes Jun 10, 2019
cb000ea
Ignore admin panel customizations in coverage
AllenAnthes Jun 10, 2019
c204b6d
Add branch as viewable and filterable field in profile admin table
AllenAnthes Jun 10, 2019
754f345
Add created_at to user profiles and migrate from old model - Ref: #24
AllenAnthes Jun 10, 2019
d5df297
Add allauth social urls, fixing 'user already exists' google login ex…
AllenAnthes Jun 10, 2019
2e77368
Bump boto3 from 1.9.163 to 1.9.164
dependabot-preview[bot] Jun 10, 2019
4fb8c94
Merge pull request #25 from OperationCode/dependabot/pip/boto3-1.9.164
AllenAnthes Jun 10, 2019
a7014ed
Bump django-widget-tweaks from 1.4.3 to 1.4.5
dependabot-preview[bot] Jun 10, 2019
3e39abd
Merge pull request #26 from OperationCode/dependabot/pip/django-widge…
AllenAnthes Jun 10, 2019
69e9c86
Tweak docker tags
AllenAnthes Jun 10, 2019
ff43247
Fix docker tags (again..)
AllenAnthes Jun 10, 2019
33ac2f3
More docker tweaking
AllenAnthes Jun 10, 2019
0a27346
Update README.md
AllenAnthes Jun 10, 2019
f31e600
Even more docker tweaking
AllenAnthes Jun 10, 2019
9766047
Stop running collectstatic on every execution
AllenAnthes Jun 10, 2019
403a4b4
Add has_housing field to Codeschool model - See #27
AllenAnthes Jun 11, 2019
0ef71fb
Commit migration
AllenAnthes Jun 11, 2019
46ea072
Bump pytest from 4.6.2 to 4.6.3
dependabot-preview[bot] Jun 11, 2019
58f7b44
Create FUNDING.yml
kylemh Jun 12, 2019
a8fe286
Merge pull request #29 from OperationCode/enable-donations
AllenAnthes Jun 12, 2019
a8c68f5
Merge pull request #28 from OperationCode/dependabot/pip/pytest-4.6.3
AllenAnthes Jun 12, 2019
4622d9e
Bump drf-yasg from 1.15.0 to 1.16.0
dependabot-preview[bot] Jun 13, 2019
25eeb1d
Merge pull request #32 from OperationCode/dependabot/pip/drf-yasg-1.16.0
AllenAnthes Jun 13, 2019
3c664ed
Bump boto3 from 1.9.165 to 1.9.168
dependabot-preview[bot] Jun 14, 2019
5815d0d
Bump psycopg2 from 2.8.2 to 2.8.3
dependabot-preview[bot] Jun 14, 2019
a233103
Cleanup circleCI config
AllenAnthes Jun 15, 2019
8bf1828
Add navbar link to API docs
AllenAnthes Jun 15, 2019
e6e3ace
Merge pull request #34 from OperationCode/dependabot/pip/boto3-1.9.168
AllenAnthes Jun 15, 2019
d23147e
Add recaptcha keys
AllenAnthes Jun 15, 2019
f5fac48
Change codeschool submit default GITHUB_REPO
AllenAnthes Jun 16, 2019
e3bb0cc
Merge pull request #35 from OperationCode/dependabot/pip/psycopg2-2.8.3
AllenAnthes Jun 16, 2019
ca7cd59
attempt initial prometheus
May 27, 2019
21fcd27
Formatting
AllenAnthes Jun 3, 2019
55a2816
Pull in updates from master
AllenAnthes Jun 10, 2019
7d96d6d
Set DB_ENGINE in prod/staging environments
AllenAnthes Jun 10, 2019
a2907f7
Switch base DB
AllenAnthes Jun 17, 2019
4d9cf0c
Merge remote-tracking branch 'origin/feature/prometheus/master' into …
AllenAnthes Jun 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
version: 2.1

orbs:
aws-ecr: circleci/aws-ecr@4.0.1
aws-ecs: circleci/aws-ecs@0.0.8

workflows:
build_test_deploy:
jobs:
Expand All @@ -19,7 +15,6 @@ workflows:
- master
- staging


jobs:
build_test:
docker:
Expand All @@ -46,8 +41,6 @@ jobs:
command: |
sudo pip install poetry
poetry install
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > /usr/local/bin/cc-test-reporter
chmod +x /usr/local/bin/cc-test-reporter

- run:
name: Initializing CodeClimate
Expand Down Expand Up @@ -103,10 +96,17 @@ jobs:
echo ${DOCKER_HUB_PASSWORD} | docker login -u ${DOCKER_HUB_USERNAME} --password-stdin

if [[ "$CIRCLE_BRANCH" == "master" ]]; then
docker build -t operationcode/back-end:${CIRCLE_BRANCH}${CIRCLE_WORKFLOW_ID} -t operationcode/back-end:latest -f docker/Dockerfile .
docker push operationcode/back-end:latest
docker build -f docker/Dockerfile --target Prod \
-t operationcode/back-end:${CIRCLE_BRANCH}-${CIRCLE_WORKFLOW_ID} \
-t operationcode/back-end:master \
-t operationcode/back-end:latest .
else
docker build -t operationcode/back-end:${CIRCLE_BRANCH}${CIRCLE_WORKFLOW_ID} -f docker/Dockerfile --target Staging .
docker build -f docker/Dockerfile --target Staging \
-t operationcode/back-end:${CIRCLE_BRANCH}-${CIRCLE_WORKFLOW_ID} \
-t operationcode/back-end:staging \
-t operationcode/back-end:latest .
fi

docker push operationcode/back-end:${CIRCLE_BRANCH}${CIRCLE_WORKFLOW_ID}
docker push operationcode/back-end:latest
docker push operationcode/back-end:${CIRCLE_BRANCH}
docker push operationcode/back-end:${CIRCLE_BRANCH}-${CIRCLE_WORKFLOW_ID}
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

custom: https://secure.lglforms.com/form_engine/s/BRtP7QUKyHOyEYsZROsRew
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@


# Welcome!

This is a work in progress rewrite of the current [OperationCode](https://operationcode.org) backend.
This is the back-end application for [OperationCode](https://operationcode.org).
We highly recommend [joining our organization](https://operationcode.org/join) to receive an invite to our Slack team.
From there, you'll want to join the `#oc-python-projects` and `#oc-projects` channels.
You can get help from multiple professional developers, including people who have worked on the application since day 1!
Our website is currently served by code located [here](https://github.com/OperationCode/operationcode_backend),
but that repository is no longer being actively developed.

Before contributing, please review our [Contributing Guide](CONTRIBUTING.md)

## Maintainers
For information about the maintainers of the project, check out [MAINTAINERS.md](MAINTAINERS.md).

## Quick Start

Recommended versions of tools used within the repo:
- `python@3.7` or greater (in some environments, you may need to specify version of python i.e. `python test.py` vs `python3 test.py`))
- `git@2.17.1` or greater
Expand Down
62 changes: 31 additions & 31 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ ENV PIP_NO_BINARY psycopg2

# copy installed deps from builder image
COPY --from=builder /opt/venv /opt/venv
# Add libpq which psycopg2 needs at runtime

# Add libpq and libjpeg which psycopg2 and pillow need at runtime
RUN apk add --no-cache libpq libjpeg-turbo

# Make sure we use the virtualenv
ENV PATH="/opt/venv/bin:$PATH"

Expand All @@ -55,19 +57,6 @@ COPY src /src
WORKDIR /src


# The `dev-base` stage is used as the base for images that require
# the development dependencies. The duplication of the COPY instruction
# avoids breaking the cache for that later when the poetry.lock changes
FROM built-image AS dev-base

ENV DJANGO_ENV development
COPY poetry.lock pyproject.toml ./
RUN pip install poetry \
&& poetry config settings.virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
COPY . /


# `Shell` will build an image that, when run, drops you into a
# python shell with the application context loaded
# Note this stage name is capitalised, this is purely
Expand All @@ -78,34 +67,45 @@ LABEL shell=true
CMD python manage.py shell


# `Dev` runs the application using the development web server, and enables
# developer tools like the debugger and interactive expcetions
FROM dev-base AS Dev
LABEL dev=true
EXPOSE 8000
WORKDIR /src

CMD python manage.py collectstatic --no-input;\
gunicorn operationcode_backend.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output --logger-class "operationcode_backend.custom_logging.CustomGunicornLogger"

# The `Staging` stage is the same configuration as prod, the only
# difference being it doesn't process background tasks
# The resulting image will run the application using a
# production webserver and configuration
# production webserver and the `environments/staging.py` configuration
FROM app As Staging

ENV DJANGO_ENV staging
EXPOSE 8000
CMD python manage.py collectstatic --no-input;\
gunicorn operationcode_backend.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output --logger-class "operationcode_backend.custom_logging.CustomGunicornLogger"
CMD gunicorn operationcode_backend.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output --logger-class "operationcode_backend.custom_logging.CustomGunicornLogger"

# The `Prod` stage is the default stage if the Dockerfile is run without
# a target stage set. The resulting image will run the application using a
# production webserver and configuration
# The `Prod` stage creates an image that will run the application using a
# production webserver and the `environments/production.py` configuration
FROM app As Prod

ENV DJANGO_ENV production
EXPOSE 8000
CMD python manage.py process_tasks &\
gunicorn operationcode_backend.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output --logger-class "operationcode_backend.custom_logging.CustomGunicornLogger"


# The `dev-base` stage is used as the base for images that require
# the development dependencies. The duplication of the COPY instruction
# avoids breaking the cache for that later when the poetry.lock changes
FROM built-image AS dev-base

ENV DJANGO_ENV development
COPY poetry.lock pyproject.toml ./
RUN pip install poetry \
&& poetry config settings.virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
COPY . /

# The `Dev` stage is the default stage if the Dockerfile is run without a target stage set.
# It runs the application using the development web server, and enables
# developer tools like the debugger and interactive expcetions
FROM dev-base AS Dev
LABEL dev=true
EXPOSE 8000
WORKDIR /src

CMD python manage.py collectstatic --no-input;\
python manage.py process_tasks &\
gunicorn operationcode_backend.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output --logger-class "operationcode_backend.custom_logging.CustomGunicornLogger"
32 changes: 2 additions & 30 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,17 @@ services:
build:
context: ..
dockerfile: docker/Dockerfile
# target: Dev
target: Staging
container_name: backend02
env_file:
- .env
# volumes:
# - ../src:/src
ports:
- 8000:8000
# depends_on:
# - db


pybot:
image: pybot:latest
container_name: pybot01
env_file:
- pybot.env
ports:
- 5000:5000



ngrok-pyback:
image: wernight/ngrok:latest
env_file:
- .ngrok.env
environment:
- NGROK_PORT=backend:8000
- NGROK_SUBDOMAIN=pyback
ports:
- 4040:4040

# db:
# image: postgres:10.1-alpine
# container_name: pg01
# ports:
# - 5434:5432
# volumes:
# - postgres_data:/var/lib/postgresql/data/

#volumes:
# postgres_data:
- 5000:5000
Loading