Skip to content

Commit

Permalink
minio connections
Browse files Browse the repository at this point in the history
  • Loading branch information
abandoned-prototype committed Nov 10, 2020
1 parent 72f7427 commit c99e8ff
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
backup/**
*.pyc
container_data
.cache
node_modules
OpenOversight/app/static/dist/*
/OpenOversight/tests/resources/.minio.sys/
__pycache__

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ populate: create_db ## Build and run containers
test: start ## Run tests
if [ -z "$(name)" ]; then \
if [ "$$(uname)" == "Darwin" ]; then \
FLASK_ENV=testing docker-compose run --rm web pytest --doctest-modules -n $$(sysctl -n hw.logicalcpu) --dist=loadfile -v tests/ app; \
FLASK_ENV=testing docker-compose run --rm web /bin/bash -c 'scripts/minio_forward.sh & pytest --doctest-modules -n "$$(sysctl -n hw.logicalcpu)" --dist=loadfile -v tests/ app'; \
else \
FLASK_ENV=testing docker-compose run --rm web pytest --doctest-modules -n $$(nproc --all) --dist=loadfile -v tests/ app; \
FLASK_ENV=testing docker-compose run --rm web /bin/bash -c 'scripts/minio_forward.sh & pytest --doctest-modules -n "$$(nproc --all)" --dist=loadfile -v tests/ app'; \
fi; \
else \
FLASK_ENV=testing docker-compose run --rm web pytest --doctest-modules -v tests/ app -k $(name); \
FLASK_ENV=testing docker-compose run --rm web /bin/bash -c 'scripts/minio_forward.sh & pytest --doctest-modules -v tests/ app -k $(name)'; \
fi

.PHONY: lint
Expand Down
2 changes: 2 additions & 0 deletions OpenOversight/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
if [ "${DOCKER_BUILD_ENV:-}" == "production" ]; then
flask run --host=0.0.0.0 --port=3000
else
# forwarding port 9000 to minio for local S3 bucket
scripts/minio_forward.sh &
yarn build
yarn watch &
flask run --host=0.0.0.0 --port=3000
Expand Down
1 change: 1 addition & 0 deletions OpenOversight/scripts/minio_forward.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ncat -k -l localhost 9000 --sh-exec "ncat minio 9000"
1 change: 1 addition & 0 deletions OpenOversight/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import random
from selenium import webdriver
import time
import threading
from xvfbwrapper import Xvfb
from faker import Faker
import csv
Expand Down
18 changes: 7 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
network_mode: "host"

web:
restart: always
Expand All @@ -29,9 +28,9 @@ services:
environment:
AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY_ID:-minio123}"
AWS_SECRET_ACCESS_KEY: "${AWS_SECRET_ACCESS_KEY:-minio123}"
S3_ENDPOINT: "${S3_ENDPOINT:-'http://localhost:9000'}"
AWS_DEFAULT_REGION: "${AWS_DEFAULT_REGION:-'us-east-1'}"
S3_BUCKET_NAME: "${S3_BUCKET_NAME:-'openoversight-test'}"
S3_ENDPOINT: "${S3_ENDPOINT:-http://localhost:9000}"
AWS_DEFAULT_REGION: "${AWS_DEFAULT_REGION:-us-east-1}"
S3_BUCKET_NAME: "${S3_BUCKET_NAME:-openoversight-test}"
APPROVE_REGISTRATIONS: "${APPROVE_REGISTRATIONS}"
FLASK_APP: app
FLASK_ENV: "${FLASK_ENV:-development}"
Expand All @@ -41,19 +40,17 @@ services:
command: scripts/entrypoint.sh
ports:
- "3000:3000"
network_mode: "host"

minio:
image: minio/minio
environment:
MINIO_ACCESS_KEY: "${AWS_ACCESS_KEY_ID}"
MINIO_SECRET_KEY: "${AWS_SECRET_ACCESS_KEY}"
MINIO_ACCESS_KEY: "${AWS_ACCESS_KEY_ID:-minio123}"
MINIO_SECRET_KEY: "${AWS_SECRET_ACCESS_KEY:-minio123}"
command: server /data
volumes:
- ./OpenOversight/tests/resources/:/data:rw
ports:
- "9000:9000"
network_mode: "host"

mc:
image: minio/mc
Expand All @@ -62,7 +59,6 @@ services:
entrypoint: >
/bin/sh -c "
sleep 10;
/usr/bin/mc config host add minio http://localhost:9000 ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY};
/usr/bin/mc policy set public minio/${S3_BUCKET_NAME};
/usr/bin/mc config host add minio http://minio:9000 ${AWS_ACCESS_KEY_ID:-minio123} ${AWS_SECRET_ACCESS_KEY:-minio123};
/usr/bin/mc policy set public minio/${S3_BUCKET_NAME:-openoversight-test};
"
network_mode: "host"
4 changes: 2 additions & 2 deletions dockerfiles/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV DISPLAY=:1
ENV GECKODRIVER_VERSION="v0.26.0"
RUN echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list
RUN wget -O - https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update && apt-get install -y xvfb firefox-esr libpq-dev python3-dev nodejs && \
RUN apt-get update && apt-get install -y xvfb firefox-esr libpq-dev python3-dev nodejs ncat && \
apt-get install -y -t stretch-backports libsqlite3-0 && apt-get clean

RUN wget https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz
Expand Down Expand Up @@ -38,7 +38,7 @@ EXPOSE 3000

ENV PATH="/usr/src/app/geckodriver:${PATH}"
ENV SECRET_KEY 4Q6ZaQQdiqtmvZaxP1If
ENV SQLALCHEMY_DATABASE_URI postgresql://openoversight:terriblepassword@localhost:5432/openoversight-dev
ENV SQLALCHEMY_DATABASE_URI postgresql://openoversight:terriblepassword@postgres/openoversight-dev

WORKDIR /usr/src/app/OpenOversight

Expand Down

0 comments on commit c99e8ff

Please sign in to comment.