Skip to content

Commit

Permalink
feat: adding nginx for serving track data (#15) (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Jul 10, 2023
1 parent 448ccbb commit 973b640
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .ci/config/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

gzip on;

# The full static data directory is mounted into the container but we only
# serve the "nginx" sub directory (with indices in the default
# configuration).
server {
location / {
root /data/nginx;
autoindex on;
}
}
}
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.conf]
indent_style = space
indent_size = 2

[*.py]
line_length=120
known_first_party=varfish
Expand Down
5 changes: 5 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@

# -- General Container Configuration -----------------------------------------

# Base directory for configuration.
# config_basedir: ./.dev/config
## In CI: set to directory with appropriate config.
config_basedir=./.ci/config

# Base directory for volumes.
# volumes_basedir: ./volumes
## In CI: set to a directory with minimal data for spinning up the containers.
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,30 @@ ln -Tsr .dev/volumes/varfish-static/data/download/worker/masked-repeat-grch38-*/
.dev/volumes/varfish-static/data/worker/grch38/features/masked_repeat.bin
ln -Tsr .dev/volumes/varfish-static/data/download/worker/masked-segdup-grch38-*/masked-segdup.bin \
.dev/volumes/varfish-static/data/worker/grch38/features/masked_seqdup.bin

##
## tracks
##

mkdir -p .dev/volumes/varfish-static/data/nginx/grch3{7,8}

paths_37=$(find .dev/volumes/varfish-static/data/download/tracks/ -type f -name '*.bed' -or -name '*.bed.gz' | sort | grep grch37)
for path in $paths_37; do
if [[ -e ${path}.tbi ]]; then
ln -sr $path ${path}.tbi .dev/volumes/varfish-static/data/nginx/grch37
else
ln -sr $path .dev/volumes/varfish-static/data/nginx/grch37
fi
done

paths_38=$(find .dev/volumes/varfish-static/data/download/tracks/ -type f -name '*.bed' -or -name '*.bed.gz' | sort | grep grch38)
for path in $paths_38; do
if [[ -e ${path}.tbi ]]; then
ln -sr $path ${path}.tbi .dev/volumes/varfish-static/data/nginx/grch38
else
ln -sr $path .dev/volumes/varfish-static/data/nginx/grch38
fi
done
```
To create an in-house database:
Expand All @@ -238,6 +262,14 @@ varfish-server-worker db to-bin \
--path-output-bin .dev/volumes/varfish-static/data/worker/grch37/strucvars/inhouse.bin
```
### Setup Configuration
The next step step is to create the configuration files in `.dev/config`.
```bash session
mkdir -p .dev/config/nginx
cp utils/nginx/nginx.conf .dev/config/nginx
```
### Startup and Check
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.override.yml-dev
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# - `3001` -- annonars
# - `3002` -- mehari
# - `3003` -- viguno
# - `3004` -- nginx
# - `3010` -- minio
# - `3011` -- minio console

Expand All @@ -29,6 +30,11 @@ services:
ports:
- "3003:8080"

# map nginx to port 3004
nginx:
ports:
- "3004:80"

# map Minio S3 to port 9000 and console to 9001
minio:
ports:
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ services:
# Mount Docker socket into container so traefik can react to events.
- "/var/run/docker.sock:/var/run/docker.sock:ro"

# -- nginx -----------------------------------------------------------------
#
# We serve static files such as browser tracks with nginx.

nginx:
container_name: nginx
hostname: nginx
image: ${image_nginx_name:-nginx}:${image_nginx_version:-1}
volumes:
- type: bind
source: ${volumes_basedir:-./.dev/volumes}/varfish-static/data
target: /data
read_only: true
- type: bind
source: ${config_basedir:-./.dev/config}/nginx/nginx.conf
target: /etc/nginx/nginx.conf

# -- Mehari ----------------------------------------------------------------
#
# Mehari provides the transcript-related information.
Expand Down
9 changes: 9 additions & 0 deletions env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,17 @@
# Version of the "mc" (Minio client) image to use.
# image_mc_version=latest

# Name of the nginx image to use.
# image_nginx_name=nginx

# Version of the nginx image to use.
# image_nginx_version=1

# -- General Container Configuration -----------------------------------------

# Base directory for configuration.
# config_basedir: ./.dev/config

# Base directory for volumes.
# volumes_basedir: ./.dev/volumes

Expand Down
35 changes: 35 additions & 0 deletions utils/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

gzip on;

# The full static data directory is mounted into the container but we only
# serve the "nginx" sub directory (with indices in the default
# configuration).
server {
location / {
root /data/nginx;
autoindex on;
}
}
}

0 comments on commit 973b640

Please sign in to comment.