Skip to content

Commit

Permalink
Migrate to icarus (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmaanT authored Feb 6, 2020
1 parent da0a510 commit e8d596c
Show file tree
Hide file tree
Showing 19 changed files with 441 additions and 392 deletions.
158 changes: 23 additions & 135 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,143 +1,31 @@
version: 2.1
executors:
docker-publisher:
environment:
IMAGE_NAME: pennlabs/platform
docker:
- image: circleci/buildpack-deps:buster
jobs:
test:
working_directory: ~/pennlabs
docker:
- image: circleci/python:3.7
environment:
PIPENV_VENV_IN_PROJECT: true
DATABASE_URL: mysql://root:password@127.0.0.1:3306/circle_test
- image: circleci/mysql:latest
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: circle_test
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
- restore_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
name: Install dependencies
command: |
sudo pip install pipenv
pipenv install -d
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.7/site-packages"
- run:
name: Lint
command: |
pipenv run flake8 .
- run:
name: Run tests
command: |
pipenv run coverage run manage.py test --settings=Platform.settings.ci
- run:
name: Upload code coverage
command: |
pipenv run codecov
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: trl
build:
executor: docker-publisher
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o image.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./image.tar
publish:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
IMAGE_TAG="0.0.${CIRCLE_BUILD_NUM}"
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
docker push $IMAGE_NAME:latest
docker push $IMAGE_NAME:$IMAGE_TAG
deploy-master:
working_directory: ~/pennlabs
docker:
- image: circleci/python:3.7
steps:
- checkout
- run:
command: |
echo -e "Host apps.pennlabs.org\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
- run:
name: Deploy master to Dokku
command: |
git push dokku@apps.pennlabs.org:platform master
deploy-development:
working_directory: ~/pennlabs
docker:
- image: circleci/python:3.7
steps:
- checkout
- run:
command: |
echo -e "Host apps.pennlabs.org\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
- run:
name: Deploy master to Dokku
command: |
git push dokku@apps.pennlabs.org:platform-dev development
orbs:
docker: circleci/docker@0.5.19
django-tools: pennlabs/django-tools@0.0.2
helm-tools: pennlabs/helm-tools@0.1.7

branch-filters: &branch-filters
filters:
branches:
only:
- master

workflows:
version: 2
build-and-deploy:
jobs:
- test
- build:
- django-tools/check:
project-name: "Platform"
- docker/publish:
requires:
- test
filters:
branches:
only: master
- publish:
requires:
- build
- django-tools/check
cache_from: "pennlabs/platform:latest"
image: pennlabs/platform
tag: "${CIRCLE_SHA1},latest"
context: docker-publish
filters:
branches:
only: master
- deploy-master:
requires:
- publish
filters:
branches:
only: master
- deploy-development:
<<: *branch-filters
- helm-tools/deploy:
requires:
- test
filters:
branches:
only: development
- docker/publish
context: k8s-deploy
<<: *branch-filters
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pennlabs/pre-commit-hooks
rev: stable
hooks:
- id: black
- id: isort
- id: flake8
25 changes: 16 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM pennlabs/shibboleth-sp-nginx
FROM pennlabs/shibboleth-sp-nginx:3.0.4

LABEL maintainer="Penn Labs"

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

WORKDIR /app/

# Install dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends -y python3.7-dev python3-distutils default-libmysqlclient-dev gcc \
Expand All @@ -20,22 +24,25 @@ COPY docker/nginx-default.conf /etc/nginx/conf.d/default.conf
COPY docker/shib_clear_headers /etc/nginx/
COPY docker/supervisord.conf /etc/supervisor/

# Copy platform dependencies
# Copy project dependencies
COPY Pipfile* /app/

# Install platform dependencies
WORKDIR /app/
# Install project dependencies
RUN pipenv install --system

# Copy platform
# Copy project files
COPY . /app/

ENV DJANGO_SETTINGS_MODULE Platform.settings.production
ENV SECRET_KEY 'temporary key just to build the docker image'

# Collect static files
RUN python3.7 /app/manage.py collectstatic
RUN python3 /app/manage.py collectstatic --noinput

# Copy mime definitions
COPY docker/mime.types /etc/mime.types

# Copy start script
COPY docker/platform-run /usr/local/bin/

EXPOSE 443

CMD ["platform-run"]
CMD ["platform-run"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Penn Labs
Copyright (c) 2020 Penn Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ verify_ssl = true

[dev-packages]
codecov = "*"
black = "==19.10b0"
unittest-xml-reporting = "*"
flake8 = "*"
flake8-isort = "*"
flake8-quotes = "*"
django-debug-toolbar = "*"
django-extensions = "*"

[packages]
dj-database-url = "*"
Expand All @@ -17,7 +20,7 @@ djangorestframework-api-key = "*"
mysqlclient = "*"
sentry-sdk = "*"
django-oauth-toolkit = "*"
django-cors-middleware = "*"
django-cors-headers = "*"
django = "*"
pyyaml = "*"
uwsgi = "*"
Expand Down
Loading

0 comments on commit e8d596c

Please sign in to comment.