mirror of https://github.com/interlegis/sapl.git
4 changed files with 150 additions and 21 deletions
@ -1,25 +1,22 @@ |
|||
language: python |
|||
|
|||
python: |
|||
- 3.5 |
|||
|
|||
services: |
|||
- postgresql |
|||
- docker |
|||
sudo: required |
|||
env: |
|||
- DOCKER_COMPOSE_VERSION: 1.17.1 |
|||
|
|||
install: |
|||
- pip install -r requirements/test-requirements.txt |
|||
|
|||
before_script: |
|||
- cp sapl/.env_test sapl/.env |
|||
- psql -c "CREATE USER sapl WITH PASSWORD 'sapl'" -U postgres; |
|||
- psql -c "CREATE DATABASE sapl OWNER sapl;" -U postgres |
|||
- ./scripts/django/check_migrations.sh |
|||
before_install: |
|||
# - sudo apt-get update |
|||
# - sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-ce |
|||
- docker-compose --version |
|||
- whereis docker-compose |
|||
# - sudo rm /usr/local/bin/docker-compose |
|||
# - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose |
|||
# - chmod +x docker-compose |
|||
# - sudo mv docker-compose /usr/local/bin |
|||
- sudo cp /usr/local/bin/docker-compose /usr/bin/docker-compose |
|||
# - sudo apt-get install -y --force-yes python python-dev py-pip build-base libffi-dev openssl-dev libgcc |
|||
# - pip install docker-compose |
|||
|
|||
script: |
|||
- ./manage.py migrate |
|||
- py.test --create-db |
|||
# - ./scripts/django/test_and_check_qa.sh |
|||
|
|||
addons: |
|||
hosts: |
|||
- 127.0.0.1 sapldb |
|||
- /usr/local/bin/docker-compose -f docker-compose.test.yml -p sapl-ci build |
|||
- /usr/local/bin/docker-compose -f docker-compose.test.yml -p sapl-ci up |
|||
|
|||
@ -0,0 +1,48 @@ |
|||
FROM alpine:3.8 |
|||
|
|||
ENV BUILD_PACKAGES postgresql-dev graphviz-dev graphviz build-base git pkgconfig \ |
|||
python3-dev libxml2-dev jpeg-dev libressl-dev libffi-dev libxslt-dev \ |
|||
nodejs py3-lxml py3-magic postgresql-client poppler-utils antiword \ |
|||
curl jq openssh-client vim bash |
|||
|
|||
RUN apk update --update-cache && apk upgrade |
|||
|
|||
RUN apk --update add fontconfig ttf-dejavu && fc-cache -fv |
|||
|
|||
RUN apk add --no-cache python3 nginx tzdata && \ |
|||
python3 -m ensurepip && \ |
|||
rm -r /usr/lib/python*/ensurepip && \ |
|||
pip3 install --upgrade pip setuptools && \ |
|||
rm -r /root/.cache && \ |
|||
rm -f /etc/nginx/conf.d/* |
|||
|
|||
RUN mkdir -p /var/interlegis/sapl && \ |
|||
apk add --update --no-cache $BUILD_PACKAGES |
|||
|
|||
WORKDIR /var/interlegis/sapl/ |
|||
|
|||
ADD . /var/interlegis/sapl/ |
|||
|
|||
COPY config/nginx/sapl.conf /etc/nginx/conf.d |
|||
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf |
|||
|
|||
RUN pip install -r /var/interlegis/sapl/requirements/dev-requirements.txt --upgrade setuptools && \ |
|||
rm -r /root/.cache |
|||
|
|||
COPY config/env_dockerfile /var/interlegis/sapl/sapl/.env |
|||
|
|||
RUN python3 manage.py collectstatic --noinput --clear |
|||
|
|||
# Remove .env(fake) e sapl.db da imagem |
|||
RUN rm -rf /var/interlegis/sapl/sapl/.env && \ |
|||
rm -rf /var/interlegis/sapl/sapl.db |
|||
|
|||
COPY test.sh /var/interlegis/sapl/ |
|||
RUN chmod +x /var/interlegis/sapl/test.sh && \ |
|||
chmod +x /var/interlegis/sapl/check_solr.sh && \ |
|||
ln -sf /dev/stdout /var/log/nginx/access.log && \ |
|||
ln -sf /dev/stderr /var/log/nginx/error.log && \ |
|||
mkdir /var/log/sapl/ && touch /var/interlegis/sapl/sapl.log && \ |
|||
ln -s /var/interlegis/sapl/sapl.log /var/log/sapl/sapl.log |
|||
|
|||
CMD ["/var/interlegis/sapl/test.sh"] |
|||
@ -0,0 +1,30 @@ |
|||
sut: |
|||
build: . |
|||
dockerfile: Dockerfile.test |
|||
restart: "no" |
|||
environment: |
|||
ADMIN_PASSWORD: interlegis |
|||
ADMIN_EMAIL: email@dominio.net |
|||
DEBUG: 'False' |
|||
EMAIL_PORT: 587 |
|||
EMAIL_USE_TLS: 'False' |
|||
EMAIL_HOST: smtp.dominio.net |
|||
EMAIL_HOST_USER: usuariosmtp |
|||
EMAIL_SEND_USER: usuariosmtp |
|||
EMAIL_HOST_PASSWORD: senhasmtp |
|||
TZ: America/Sao_Paulo |
|||
links: |
|||
- sapldb |
|||
ports: |
|||
- "81:80" |
|||
|
|||
sapldb: |
|||
image: postgres:10.5-alpine |
|||
restart: "no" |
|||
environment: |
|||
POSTGRES_PASSWORD: sapl |
|||
POSTGRES_USER: sapl |
|||
POSTGRES_DB: sapl |
|||
PGDATA : /var/lib/postgresql/data/ |
|||
ports: |
|||
- "5434:5432" |
|||
@ -0,0 +1,54 @@ |
|||
#!/bin/bash |
|||
|
|||
create_env() { |
|||
echo "[ENV FILE] creating .env file..." |
|||
# check if file exists |
|||
if [ -f "/var/interlegis/sapl/data/secret.key" ]; then |
|||
KEY=`cat /var/interlegis/sapl/data/secret.key` |
|||
else |
|||
KEY=`python3 genkey.py` |
|||
echo $KEY > data/secret.key |
|||
fi |
|||
|
|||
FILENAME="/var/interlegis/sapl/sapl/.env" |
|||
|
|||
if [ -z "${DATABASE_URL:-}" ]; then |
|||
DATABASE_URL="postgresql://sapl:sapl@sapldb:5432/sapl" |
|||
fi |
|||
|
|||
# ALWAYS replace the content of .env variable |
|||
# If want to conditionally create only if absent then use IF below |
|||
# if [ ! -f $FILENAME ]; then |
|||
|
|||
touch $FILENAME |
|||
|
|||
|
|||
# explicitly use '>' to erase any previous content |
|||
echo "SECRET_KEY="$KEY > $FILENAME |
|||
# now only appends |
|||
echo "DATABASE_URL = "$DATABASE_URL >> $FILENAME |
|||
echo "DEBUG = ""${DEBUG-False}" >> $FILENAME |
|||
echo "EMAIL_USE_TLS = ""${USE_TLS-True}" >> $FILENAME |
|||
echo "EMAIL_PORT = ""${EMAIL_PORT-587}" >> $FILENAME |
|||
echo "EMAIL_HOST = ""${EMAIL_HOST-''}" >> $FILENAME |
|||
echo "EMAIL_HOST_USER = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
|||
echo "EMAIL_HOST_PASSWORD = ""${EMAIL_HOST_PASSWORD-''}" >> $FILENAME |
|||
echo "EMAIL_SEND_USER = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
|||
echo "DEFAULT_FROM_EMAIL = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
|||
echo "SERVER_EMAIL = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
|||
echo "USE_SOLR = ""${USE_SOLR-False}" >> $FILENAME |
|||
echo "SOLR_COLLECTION = ""${SOLR_COLLECTION-sapl}" >> $FILENAME |
|||
echo "SOLR_URL = ""${SOLR_URL-http://localhost:8983}" >> $FILENAME |
|||
|
|||
|
|||
echo "[ENV FILE] done." |
|||
} |
|||
|
|||
create_env |
|||
|
|||
/bin/bash busy-wait.sh $DATABASE_URL |
|||
|
|||
|
|||
python3 manage.py migrate |
|||
#./scripts/django/check_migrations.sh |
|||
py.test --create-db |
|||
Loading…
Reference in new issue