Skip to content

Commit 8bf4f69

Browse files
Place db behind reverse-proxy.
1 parent 5b709b6 commit 8bf4f69

File tree

5 files changed

+62
-10
lines changed

5 files changed

+62
-10
lines changed

LNX-docker-compose.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ services:
1414
fakeservices.datajoint.io:
1515
condition: service_healthy
1616
environment:
17-
- DJ_HOST=db
17+
- DJ_HOST=fakeservices.datajoint.io
1818
- DJ_USER=root
1919
- DJ_PASS=simple
20-
- DJ_TEST_HOST=db
20+
- DJ_TEST_HOST=fakeservices.datajoint.io
2121
- DJ_TEST_USER=datajoint
2222
- DJ_TEST_PASSWORD=datajoint
2323
- S3_ENDPOINT=fakeservices.datajoint.io:9000
@@ -57,10 +57,10 @@ services:
5757
# - ./mysql/data:/var/lib/mysql
5858
minio:
5959
<<: *net
60+
image: minio/minio:$MINIO_VER
6061
environment:
6162
- MINIO_ACCESS_KEY=datajoint
6263
- MINIO_SECRET_KEY=datajoint
63-
image: minio/minio:$MINIO_VER
6464
# ports:
6565
# - "9000:9000"
6666
# volumes:
@@ -79,6 +79,7 @@ services:
7979
- URL=datajoint.io
8080
- SUBDOMAINS=fakeservices
8181
- MINIO_SERVER=http://minio:9000
82+
- MYSQL_SERVER=db:3306
8283
entrypoint: /entrypoint.sh
8384
healthcheck:
8485
test: wget --quiet --tries=1 --spider https://fakeservices.datajoint.io:443/minio/health/live || exit 1
@@ -88,8 +89,10 @@ services:
8889
# ports:
8990
# - "9000:9000"
9091
# - "443:443"
92+
# - "3306:3306"
9193
volumes:
9294
- ./tests/nginx/base.conf:/base.conf
95+
- ./tests/nginx/nginx.conf:/nginx.conf
9396
- ./tests/nginx/entrypoint.sh:/entrypoint.sh
9497
- ./tests/nginx/fullchain.pem:/certs/fullchain.pem
9598
- ./tests/nginx/privkey.pem:/certs/privkey.pem

local-docker-compose.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ services:
1414
fakeservices.datajoint.io:
1515
condition: service_healthy
1616
environment:
17-
- DJ_HOST=db
17+
- DJ_HOST=fakeservices.datajoint.io
1818
- DJ_USER=root
1919
- DJ_PASS=simple
20-
- DJ_TEST_HOST=db
20+
- DJ_TEST_HOST=fakeservices.datajoint.io
2121
- DJ_TEST_USER=datajoint
2222
- DJ_TEST_PASSWORD=datajoint
2323
# If running tests locally, make sure to add entry in /etc/hosts for 127.0.0.1 fakeservices.datajoint.io
@@ -35,7 +35,7 @@ services:
3535
pip install --user nose nose-cov coveralls ptvsd .;
3636
pip freeze | grep datajoint;
3737
## You may run the below tests once sh'ed into container i.e. docker exec -it datajoint-python_app_1 sh
38-
# nosetests -vsw tests --with-coverage --cover-package=datajoint; #run all tests
38+
# nosetests -vsw tests; #run all tests
3939
# nosetests -vs --tests=tests.test_external_class:test_insert_and_fetch; #run specific basic test
4040
# nosetests -vs --tests=tests.test_fetch:TestFetch.test_getattribute_for_fetch1; #run specific Class test
4141
## Interactive Jupyter Notebook environment
@@ -61,17 +61,19 @@ services:
6161
image: datajoint/mysql:$MYSQL_VER
6262
environment:
6363
- MYSQL_ROOT_PASSWORD=simple
64-
ports:
65-
- "3306:3306"
64+
# ports:
65+
# - "3306:3306"
6666
# To persist MySQL data
6767
# volumes:
6868
# - ./mysql/data:/var/lib/mysql
6969
minio:
7070
<<: *net
71+
image: minio/minio:$MINIO_VER
7172
environment:
7273
- MINIO_ACCESS_KEY=datajoint
7374
- MINIO_SECRET_KEY=datajoint
74-
image: minio/minio:$MINIO_VER
75+
# ports:
76+
# - "9000:9000"
7577
# To persist MinIO data and config
7678
# volumes:
7779
# - ./minio/data:/data
@@ -89,6 +91,7 @@ services:
8991
- URL=datajoint.io
9092
- SUBDOMAINS=fakeservices
9193
- MINIO_SERVER=http://minio:9000
94+
- MYSQL_SERVER=db:3306
9295
entrypoint: /entrypoint.sh
9396
healthcheck:
9497
test: wget --quiet --tries=1 --spider https://fakeservices.datajoint.io:443/minio/health/live || exit 1
@@ -98,8 +101,10 @@ services:
98101
ports:
99102
- "9000:9000"
100103
- "443:443"
104+
- "3306:3306"
101105
volumes:
102106
- ./tests/nginx/base.conf:/base.conf
107+
- ./tests/nginx/nginx.conf:/nginx.conf
103108
- ./tests/nginx/entrypoint.sh:/entrypoint.sh
104109
- ./tests/nginx/fullchain.pem:/certs/fullchain.pem
105110
- ./tests/nginx/privkey.pem:/certs/privkey.pem

tests/nginx/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
sed "s|{{SUBDOMAINS}}|${SUBDOMAINS}|g" /base.conf | tee /etc/nginx/conf.d/base.conf
33
sed -i "s|{{URL}}|${URL}|g" /etc/nginx/conf.d/base.conf
44
sed -i "s|{{MINIO_SERVER}}|${MINIO_SERVER}|g" /etc/nginx/conf.d/base.conf
5+
sed "s|{{MYSQL_SERVER}}|${MYSQL_SERVER}|g" /nginx.conf | tee /etc/nginx/nginx.conf
56
nginx -g "daemon off;"

tests/nginx/nginx.conf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
user nginx;
3+
worker_processes auto;
4+
5+
error_log /var/log/nginx/error.log warn;
6+
pid /var/run/nginx.pid;
7+
8+
9+
events {
10+
worker_connections 1024;
11+
}
12+
13+
stream {
14+
upstream target_db {
15+
server {{MYSQL_SERVER}};
16+
}
17+
18+
server {
19+
listen 3306;
20+
proxy_pass target_db;
21+
}
22+
}
23+
24+
http {
25+
include /etc/nginx/mime.types;
26+
default_type application/octet-stream;
27+
28+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
29+
'$status $body_bytes_sent "$http_referer" '
30+
'"$http_user_agent" "$http_x_forwarded_for"';
31+
32+
access_log /var/log/nginx/access.log main;
33+
34+
sendfile on;
35+
#tcp_nopush on;
36+
37+
keepalive_timeout 65;
38+
39+
#gzip on;
40+
41+
include /etc/nginx/conf.d/*.conf;
42+
}

tests/test_privileges.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class TestUnprivileged:
1111
@classmethod
1212
def setup_class(cls):
1313
"""A connection with only SELECT privilege to djtest schemas"""
14-
cls.connection = dj.Connection(host=CONN_INFO['host'], user='djview', password='djview')
14+
cls.connection = dj.conn(host=CONN_INFO['host'], user='djview', password='djview',
15+
reset=True)
1516

1617
@raises(dj.DataJointError)
1718
def test_fail_create_schema(self):

0 commit comments

Comments
 (0)