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

Fix bootstrap #11

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b08d086
page break between worksheet content
sumandari Feb 10, 2021
8fc3a49
update worksheet styling
sumandari Feb 23, 2021
557956f
fix CourseType urls patterns
sumandari Aug 1, 2021
7d91d39
added github actions for test
sumandari Aug 7, 2021
b2c0978
fix error flake8
sumandari Aug 7, 2021
be431ee
updated github action
sumandari Aug 8, 2021
f1024ff
added test always fail
sumandari Aug 8, 2021
3c046e4
deleted test_always_fail.py
sumandari Aug 8, 2021
dd49a84
add GitHub OAuth setup information (#1263)
Aug 8, 2021
4f10d4d
Refactor PR test action
lucernae Aug 9, 2021
31b088c
Merge pull request #10 from lucernae/feature_github_action_test_pr
sumandari Aug 9, 2021
3ed431d
Merge pull request #1361 from sumandari/feature_github_action_test_pr
Aug 11, 2021
424be52
remove CODECOV_TOKEN flag for public repo
lucernae Aug 9, 2021
cc43031
merge github action for latest and PR branches
lucernae Aug 11, 2021
557c2fa
Merge pull request #1362 from lucernae/feature_github_action_test_pr
Aug 11, 2021
298f14b
Merge remote-tracking branch 'upstream/develop' into fix_url_course_type
sumandari Aug 13, 2021
a890fda
Merge pull request #1360 from sumandari/fix_url_course_type
Aug 13, 2021
154bbe6
Merge pull request #1294 from sumandari/1240c_pagebreak
Aug 13, 2021
58aec98
Merge pull request #1311 from sumandari/1268_answersheet_styling
Aug 13, 2021
44a9d23
Validate the uploaded zipfile (#1314)
Aug 20, 2021
571c1a9
added boostrap files to static
sumandari Oct 1, 2021
9b53553
fix error apt-get update
sumandari Oct 1, 2021
11c741f
used cdn for font-awesome
sumandari Oct 1, 2021
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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ max-line-length = 79
# E12x continuation line indentation
# E251 no spaces around keyword / parameter equals
# E303 too many blank lines (3)
ignore = E125,E126,E251,E303,W504,W60
ignore = E125,E126,E251,E303,W504,W60,F405
115 changes: 111 additions & 4 deletions .github/workflows/build-push-images-latest.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,116 @@
name: latest-build
on:
workflow_dispatch:
pull_request:
branches:
- develop
push:
branches:
- develop
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.7
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2

- name: Test installing development dependencies
working-directory: deployment/docker
run: |
python -m pip install --upgrade pip
pip install -r REQUIREMENTS-dev.txt

- name: Run Flake8 test
run: flake8 .

test:
runs-on: ubuntu-latest
needs:
- lint
env:
APP_IMAGE: kartoza/projecta-uwsgi
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build test image
uses: docker/build-push-action@v2
with:
context: .
file: deployment/docker/Dockerfile
push: false
load: true
target: dev
tags: ${{ env.APP_IMAGE }}:dev
cache-from: |
type=gha,scope=test
type=gha,scope=prod
cache-to: type=gha,scope=test

- name: Build prod image
uses: docker/build-push-action@v2
with:
context: .
file: deployment/docker/Dockerfile
push: false
load: true
target: dev
tags: ${{ env.APP_IMAGE }}:prod
cache-from: |
type=gha,scope=test
type=gha,scope=prod
cache-to: type=gha,scope=prod

- name: Run docker-compose services
working-directory: deployment
run: |
echo "Override docker-compose for testing purposes"
cp .env.example .env
cp docker-compose.test.yml docker-compose.override.yml
make up
make devweb
make wait-db
make create-test-db

- name: Run Coverage test
working-directory: deployment
run: |
cat << EOF | docker-compose exec -T devweb bash
python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic --noinput --verbosity 0
coverage run manage.py test
coverage xml
EOF
docker cp projecta_devweb_1:/home/web/django_project/coverage.xml ../coverage.xml

- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true

docker-builder:
# Only push if PR happens in the same repo
if: github.event.pull_request.base.repo.url == github.event.pull_request.head.repo.url
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand All @@ -21,11 +119,13 @@ jobs:

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v3
with:
images: ${{ secrets.DOCKERHUB_REPO }}/projecta-uwsgi
tag-match: \d{1,3}.\d{1,3}.\d{1,3}
tag-semver: true
tags: |
type=semver,pattern=\d.\d.\d
type=ref,event=branch
type=ref,event=pr

- name: Build and push
id: docker_build
Expand All @@ -34,6 +134,13 @@ jobs:
context: .
file: deployment/docker/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}/projecta-uwsgi:latest
target: prod
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: |
type=gha,scope=test
type=gha,scope=prod
cache-to: type=gha,scope=prod

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
39 changes: 0 additions & 39 deletions .github/workflows/build-push-images-pr.yaml

This file was deleted.

15 changes: 13 additions & 2 deletions .github/workflows/build-push-images-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ jobs:
context: .
file: deployment/docker/Dockerfile
push: true
target: prod
tags: ${{ secrets.DOCKERHUB_REPO }}/projecta-uwsgi:${{ github.event.inputs.tags }}
cache-from: type=gha,scope=prod
cache-to: type=gha,scope=prod
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

Expand All @@ -59,10 +62,13 @@ jobs:

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v3
with:
images: ${{ secrets.DOCKERHUB_REPO }}/projecta-uwsgi
tag-match: \d{1,3}.\d{1,3}.\d{1,3}
tags: |
type=semver,pattern=\d.\d.\d
type=ref,event=branch
type=ref,event=pr

- name: Build and push
id: docker_build
Expand All @@ -71,6 +77,11 @@ jobs:
context: .
file: deployment/docker/Dockerfile
push: true
target: prod
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha,scope=prod
cache-to: type=gha,scope=prod

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
3 changes: 3 additions & 0 deletions .github/workflows/build-push-images-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
context: .
file: deployment/docker/Dockerfile
push: true
target: prod
tags: ${{ secrets.DOCKERHUB_REPO }}/projecta-uwsgi:stable
cache-from: type=gha,scope=prod
cache-to: type=gha,scope=prod
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
48 changes: 48 additions & 0 deletions README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,54 @@ I made a general overview screencast describing this process here:
Tim write stuff here....


## Setup Github OAuth
To configure OAuth application on Github, go to [https://github.com/settings/developers](https://github.com/settings/developers) and click on your project or create a new project at [https://github.com/settings/applications/new](https://github.com/settings/applications/new)

It is mandatory to fill out Application Name, Homepage URL, and Authorization callback URL:
- **Application Name**: changelog.kartoza.com
- **Homepage URL**: https://changelog.kartoza.com
- **Authorization callback URL**: https://changelog.kartoza.com/accounts/github/login/callback/

![image (1)](https://user-images.githubusercontent.com/40058076/103614680-2a4dd580-4f64-11eb-8dca-0466f17a5849.png)



Click the `Update application` button and generate Client secret by click on `Generate a new client secret` button.

![image (3)](https://user-images.githubusercontent.com/40058076/103614687-2d48c600-4f64-11eb-85b7-f6145db9f139.png)



Now you have `Client ID` and `Client Secret`

![image (2)](https://user-images.githubusercontent.com/40058076/103614683-2b7f0280-4f64-11eb-9010-ddbc378bafe8.png)



Go to django admin site: Home > Sites > Sites, and click on `Add Site` button:
- **Domain name**: changelog.kartoza.com
- **Display name**: changelog.kartoza.com

![doc_001](https://user-images.githubusercontent.com/40058076/103616775-04c2cb00-4f68-11eb-9fd3-0eef6569f92c.png)



Go to django admin site: Home > Social Accounts > Social applications and `Add social application` button:
- **Provider**: Github
- **Name**: https://changelog.kartoza.com
- **Client id**: your `Client ID`
- **Secret key**: your `Client secret`
- **Choosen sites**: changelog.kartoza.com

![doc_002](https://user-images.githubusercontent.com/40058076/103617160-b530cf00-4f68-11eb-9d97-0dfbcf4e6536.png)



Go to your website, login with Github and you'll be redirected to the Github authorize page.

![image (4)](https://user-images.githubusercontent.com/40058076/103614651-17d39c00-4f64-11eb-97b7-6181133e4c86.png)


## Developer FAQ

**Q**: I get ``ImportError: Could not import settings core.settings.dev_docker``
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ coverage:
range: 50..75
round: down
precision: 2
fixes:
- "/home/web/django_project/::django_project/"
7 changes: 7 additions & 0 deletions deployment/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ db:
@echo "------------------------------------------------------------------"
@docker-compose up -d db

wait-db:
@docker-compose exec -T db su - postgres -c "until pg_isready; do sleep 5; done"

create-test-db:
@docker-compose exec -T db su - postgres -c "psql -c 'create database test_db;'"
@docker-compose exec -T db su - postgres -c "psql -d test_db -c 'create extension postgis;'"

nginx:
@echo
@echo "------------------------------------------------------------------"
Expand Down
6 changes: 4 additions & 2 deletions deployment/docker-compose.override.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
build:
context: ${PWD}/../
dockerfile: deployment/docker/Dockerfile
target: prod
volumes:
- ../django_project:/home/web/django_project
- ./logs:/var/log
Expand All @@ -52,8 +53,9 @@ services:
devweb:
image: kartoza/project-uwsgi:dev-latest
build:
context: docker
dockerfile: Dockerfile-dev
context: ${PWD}/../
dockerfile: deployment/docker/Dockerfile
target: dev
volumes:
- ../django_project:/home/web/django_project
- ./logs:/var/log
Expand Down
9 changes: 9 additions & 0 deletions deployment/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3'
services:
uwsgi: &uwsgi-common
image: ${APP_IMAGE}:prod

devweb:
image: ${APP_IMAGE}:dev
environment:
DJANGO_SETTINGS_MODULE: core.settings.test_docker
36 changes: 35 additions & 1 deletion deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#--------- Generic stuff all our Dockerfiles should start with so we get caching ------------
# Note this base image is based on debian
FROM kartoza/django-base:3.7
FROM kartoza/django-base:3.7 as prod
MAINTAINER Tim Sutton<[email protected]>

#RUN ln -s /bin/true /sbin/initctl
Expand Down Expand Up @@ -29,3 +29,37 @@ EXPOSE 8080

WORKDIR /home/web/django_project
CMD ["uwsgi", "--ini", "/uwsgi.conf"]

FROM prod as dev

# This section taken on 2 July 2015 from
# https://docs.docker.com/examples/running_ssh_service/
# Sudo is needed by pycharm when it tries to pip install packages
RUN apt-get update -y; apt-get install -y openssh-server sudo
RUN mkdir /var/run/sshd
RUN echo 'root:docker' | chpasswd
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config


# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

# End of cut & paste section

ADD deployment/docker/REQUIREMENTS-dev.txt /REQUIREMENTS-dev.txt
RUN pip install -r /REQUIREMENTS-dev.txt
ADD deployment/docker/bashrc /root/.bashrc

# --------------------------------------------------------
# Open ports as needed
# --------------------------------------------------------

# Open port 8080 as we will be running our django dev server on
EXPOSE 8080
# Open port 22 as we will be using a remote interpreter from pycharm
EXPOSE 22

CMD ["/usr/sbin/sshd", "-D"]
Loading