Skip to content

Commit c5a2d97

Browse files
edwardoliveiraeribeiro
and
eribeiro
authored
Refatora arquivos Docker (#3264)
* Refatora arquivos Docker * Conserta runtime * Retorna CI antigo Co-authored-by: eribeiro <[email protected]>
1 parent 5d48f8b commit c5a2d97

28 files changed

+155
-63
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: python
22

33
python:
4-
- 3.6
4+
- 3.7
55

66
services:
77
- postgresql

Dockerfile docker/Dockerfile

+13-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ RUN apt-get update && \
3333
SUDO_FORCE_REMOVE=yes apt-get purge -y --auto-remove $BUILD_PACKAGES && \
3434
apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*
3535

36-
COPY start.sh /var/interlegis/sapl/
37-
COPY config/nginx/sapl.conf /etc/nginx/conf.d
38-
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf
39-
40-
COPY config/env_dockerfile /var/interlegis/sapl/sapl/.env
36+
ENV HOME=/var/interlegis/sapl
37+
38+
COPY docker/start.sh $HOME
39+
COPY docker/check_solr.sh $HOME
40+
COPY docker/solr_api.py $HOME
41+
COPY docker/busy-wait.sh $HOME
42+
COPY docker/create_admin.py $HOME
43+
COPY docker/genkey.py $HOME
44+
COPY docker/gunicorn_start.sh $HOME
45+
46+
COPY docker/config/nginx/sapl.conf /etc/nginx/conf.d
47+
COPY docker/config/nginx/nginx.conf /etc/nginx/nginx.conf
48+
COPY docker/config/env_dockerfile /var/interlegis/sapl/sapl/.env
4149

4250
RUN python3 manage.py collectstatic --noinput --clear
4351

Dockerfile.dev docker/Dockerfile.dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM python:3.6
22
ENV PYTHONUNBUFFERED 1
33
WORKDIR /sapl-dev
4-
COPY requirements ./requirements/
4+
COPY ../requirements ./requirements/
55
RUN apt update && \
66
apt -y install graphviz-dev && \
77
pip install --upgrade pip && \

busy-wait.sh docker/busy-wait.sh

File renamed without changes.

check_solr.sh docker/check_solr.sh

File renamed without changes.

config/env-sample docker/config/env-sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DATABASE_URL = postgresql://postgres:@sapldb:/sapl
2-
KEY
2+
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb'
33
DEBUG = False
44
EMAIL_USE_TLS = True
55
EMAIL_PORT = 587

config/env_dockerfile docker/config/env_dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DATABASE_URL = sqlite:///sapl.db
2-
SECRET_KEY = 'Dockerfile_Key'
2+
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb'
33
DEBUG = False
44
EMAIL_USE_TLS = True
55
EMAIL_PORT = 587

docker/config/env_test

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DATABASE_URL=postgresql://sapl:sapl@sapldb:/sapl
2+
SECRET_KEY=test++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb
3+
DEBUG=False
4+
EMAIL_USE_TLS = True
5+
EMAIL_PORT = 587
6+
EMAIL_HOST = ''
7+
EMAIL_HOST_USER = ''
8+
EMAIL_SEND_USER = ''
9+
EMAIL_HOST_PASSWORD = ''
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docker/docker-compose-test.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
version: "3.7"
2+
services:
3+
sapldb:
4+
image: postgres:10.5-alpine
5+
restart: always
6+
container_name: postgres
7+
labels:
8+
NAME: "postgres"
9+
environment:
10+
POSTGRES_PASSWORD: sapl
11+
POSTGRES_USER: sapl
12+
POSTGRES_DB: sapl
13+
PGDATA : /var/lib/postgresql/data/
14+
volumes:
15+
- sapldb_data:/var/lib/postgresql/data/
16+
ports:
17+
- "5433:5432"
18+
networks:
19+
- sapl-net
20+
saplsolr:
21+
image: solr:8.3
22+
restart: always
23+
command: bin/solr start -c -f
24+
container_name: solr
25+
labels:
26+
NAME: "solr"
27+
volumes:
28+
- solr_data:/opt/solr/server/solr
29+
- solr_configsets:/opt/solr/server/solr/configsets
30+
ports:
31+
- "8983:8983"
32+
networks:
33+
- sapl-net
34+
sapl:
35+
build:
36+
context: ../
37+
dockerfile: ./docker/Dockerfile
38+
container_name: sapl
39+
labels:
40+
NAME: "sapl"
41+
restart: always
42+
environment:
43+
ADMIN_PASSWORD: interlegis
44+
ADMIN_EMAIL: [email protected]
45+
DEBUG: 'False'
46+
EMAIL_PORT: 587
47+
EMAIL_USE_TLS: 'False'
48+
EMAIL_HOST: smtp.dominio.net
49+
EMAIL_HOST_USER: usuariosmtp
50+
EMAIL_SEND_USER: usuariosmtp
51+
EMAIL_HOST_PASSWORD: senhasmtp
52+
USE_SOLR: 'True'
53+
SOLR_COLLECTION: sapl
54+
SOLR_URL: http://saplsolr:8983
55+
TZ: America/Sao_Paulo
56+
volumes:
57+
- sapl_data:/var/interlegis/sapl/data
58+
- sapl_media:/var/interlegis/sapl/media
59+
depends_on:
60+
- sapldb
61+
- saplsolr
62+
ports:
63+
- "80:80"
64+
networks:
65+
- sapl-net
66+
networks:
67+
sapl-net:
68+
name: sapl-net
69+
driver: bridge
70+
volumes:
71+
sapldb_data:
72+
sapl_data:
73+
sapl_media:
74+
solr_data:
75+
solr_configsets:

docker-compose.yml docker/docker-compose.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ services:
33
sapldb:
44
image: postgres:10.5-alpine
55
restart: always
6+
container_name: postgres
7+
labels:
8+
NAME: "postgres"
69
environment:
710
POSTGRES_PASSWORD: sapl
811
POSTGRES_USER: sapl
@@ -18,6 +21,9 @@ services:
1821
image: solr:8.3
1922
restart: always
2023
command: bin/solr start -c -f
24+
container_name: solr
25+
labels:
26+
NAME: "solr"
2127
volumes:
2228
- solr_data:/opt/solr/server/solr
2329
- solr_configsets:/opt/solr/server/solr/configsets
@@ -27,7 +33,12 @@ services:
2733
- sapl-net
2834
sapl:
2935
image: interlegis/sapl:3.1.161-RC13
30-
#build: .
36+
# build:
37+
# context: ../
38+
# dockerfile: ./docker/Dockerfile
39+
container_name: sapl
40+
labels:
41+
NAME: "sapl"
3142
restart: always
3243
environment:
3344
ADMIN_PASSWORD: interlegis

docker-env.sh docker/docker-env.sh

File renamed without changes.

genkey.py docker/genkey.py

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

solr_api.py docker/solr_api.py

File renamed without changes.

start.sh docker/start.sh

File renamed without changes.

docker/travis.yml.docker

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
sudo: required
2+
3+
services:
4+
- docker
5+
6+
env:
7+
global:
8+
- DOCKER_COMPOSE_VERSION=1.26.2
9+
10+
before_install:
11+
# Install latest versions of docker and docker-compose
12+
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
13+
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
14+
- sudo apt-get update
15+
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
16+
- sudo rm /usr/local/bin/docker-compose
17+
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
18+
- chmod +x docker-compose
19+
- sudo mv docker-compose /usr/local/bin
20+
- docker --version
21+
- docker-compose --version
22+
23+
install:
24+
- sudo service postgresql stop || true
25+
26+
script:
27+
- cd $TRAVIS_BUILD_DIR/docker
28+
# Build master images and run the webserver (tests end to end)
29+
#- docker-compose -f docker-compose.test.yml build
30+
#- docker-compose up -d
31+
#- docker logs sapl
32+
#- docker-compose rm -f -s -v
33+
- docker-compose -f docker-compose-test.yml run --workdir="/var/interlegis/sapl" sapl bash -c "bash busy-wait.sh postgresql://sapl:sapl@sapldb:5432/sapl && cp docker/config/env_test .env && py.test --create-db"
34+
35+
after_script:
36+
# Cleanup docker containers, images, and volumes
37+
- docker-compose rm -f -s -v
38+
- docker system prune -a -f --volumes

health_check.py

-49
This file was deleted.

release.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ FINAL_VERSION=
3030

3131
function change_files {
3232

33-
OLD_VERSION=$(grep -E 'interlegis/sapl:'$VERSION_PATTERN docker-compose.yml | cut -d':' -f3)
33+
OLD_VERSION=$(grep -E 'interlegis/sapl:'$VERSION_PATTERN docker/docker-compose.yml | cut -d':' -f3)
3434

3535
echo "Atualizando de "$OLD_VERSION" para "$FINAL_VERSION
3636

37-
sed -E -i "s|$OLD_VERSION|$FINAL_VERSION|g" docker-compose.yml
37+
sed -E -i "s|$OLD_VERSION|$FINAL_VERSION|g" docker/docker-compose.yml
3838

3939
sed -E -i "s|$OLD_VERSION|$FINAL_VERSION|g" setup.py
4040

@@ -65,7 +65,7 @@ function set_rc_version {
6565

6666
function commit_and_push {
6767
echo "committing..."
68-
git add docker-compose.yml setup.py sapl/settings.py sapl/templates/base.html
68+
git add docker/docker-compose.yml setup.py sapl/settings.py sapl/templates/base.html
6969
git commit -m "Release: $FINAL_VERSION"
7070
git tag $FINAL_VERSION
7171

sapl/.env_test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DATABASE_URL = postgresql://postgres:@sapldb:/sapl
2-
SECRET_KEY=TravisTest
2+
SECRET_KEY=test++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb
33
DEBUG=False
44
EMAIL_USE_TLS = True
55
EMAIL_PORT = 587

0 commit comments

Comments
 (0)