Skip to content

Commit

Permalink
adding initial dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
havok2063 committed Feb 22, 2024
1 parent d4e7bc9 commit 07535ce
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 22 deletions.
37 changes: 16 additions & 21 deletions Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,23 @@ FROM python:3.10-slim
# Set the working directory in the container
WORKDIR /app

# Install git
# Install library files
RUN apt-get update && \
apt-get install -y git && \
apt-get install -y --no-install-recommends git libpq-dev gcc build-essential mime-support && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Clone the repository and checkout the specific tag
# RUN git clone https://github.com/sdss/marvin.git /app && \
# git checkout tags/2.8.0
COPY . /app

#RUN pip install "psycopg2<2.9"
#RUN pip install psycopg2-binary

# Install deps for psycopg2
RUN apt-get update \
&& apt-get -y install libpq-dev gcc \
&& pip install psycopg2
RUN git clone https://github.com/sdss/marvin.git /app && \
git checkout docker
#COPY . /app


# Install any needed packages
RUN pip install --no-cache-dir ".[web,db]"

# Install uWSGI
RUN pip install gunicorn uvicorn
# Resolve some dependency issues
RUN pip install gunicorn
RUN pip install "jinja2<3.1"
RUN pip install "packaging<21"
RUN pip install "itsdangerous==2.0.1"
Expand All @@ -41,18 +33,21 @@ RUN mkdir -p /tmp/marvin/logs && \
# Make port 8000 available to the world outside this container
EXPOSE 8000

# Copy your uWSGI ini file into the container
#COPY python/marvin/web/uwsgi_conf_files/docker.py /app/python/marvin/web/uwsgi_conf_files/docker.py
# Copy the gunicorn config file into the container
COPY ./gunicorn_config.py /app/python/gunicorn_config.py

# Create the marvin config file
RUN mkdir -p /root/.marvin && chmod -R 755 /root/.marvin
RUN echo "use_sentry: False\nadd_github_message: False\ncheck_access: False" > /root/.marvin/marvin.yml

ENV FLASK_ENV=docker
# Update permissions
RUN chmod -R 755 /app/python/marvin/web

# Set environment variables
ENV FLASK_APP="marvin.web.uwsgi_conf_files.app:app"

# Change to python dir
WORKDIR /app/python

# Run the application with uWSGI
#CMD ["uwsgi", "--ini", "/app/python/marvin/web/uwsgi_conf_files/docker.ini"]
#CMD ["gunicorn", "-w", "1", "-b", ":8000", "marvin.web.uwsgi_conf_files.app:app"]
CMD ["gunicorn", "-c", "/app/python/marvin/web/uwsgi_conf_files/docker.py", "marvin.web.uwsgi_conf_files.app:app"]
CMD ["gunicorn", "-c", "gunicorn_config.py", "marvin.web.uwsgi_conf_files.app:app"]
63 changes: 63 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: '3.9'
services:
nginx:
container_name: nginx
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- socket_logs:/tmp/marvin
- web_assets:/usr/share/nginx/html
ports:
- 8080:80
depends_on:
- marvin
networks:
- frontend

redis:
container_name: redis
image: redis:latest
networks:
- backend

# db:
# image: postgres:latest
# volumes:
# - ./dbdata/:/var/lib/postgresql/data
# environment:
# POSTGRES_DB: manga
# POSTGRES_USER: ${MANGADB_USER}
# POSTGRES_PASSWORD: ${MANGADB_PASS}
# networks:
# - backend

marvin:
container_name: marvin
image: marvin:latest
ports:
- 8000:8000
volumes:
- ${SAS_BASE_DIR}:/root/sas/
- $HOME/.pgpass:/root/.pgpass
- socket_logs:/tmp/marvin
- web_assets:/app/python/marvin/web
environment:
- SESSION_REDIS=redis://redis:6379
- MARVIN_BASE=marvin
- PUBLIC_SERVER=True
- MANGADB_CONFIG=docker
networks:
- backend
- frontend
depends_on:
- redis
#- db


networks:
backend:
frontend:

volumes:
socket_logs:
web_assets:
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
daemon = False
errorlog = os.path.join(os.getenv("MARVIN_LOGS_DIR", '/tmp/marvin/logs'), 'marvin_app_error.log')
accesslog = os.path.join(os.getenv("MARVIN_LOGS_DIR", '/tmp/marvin/logs'), 'marvin_app_access.log')
root_path = '/marvin'
108 changes: 108 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
events {
use epoll;
worker_connections 51200;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
# gzip on;
# gzip_disable "msie6";

#error_log /etc/nginx/nginx-error.log warn;
#access_log /etc/nginx/nginx-access.log;

client_max_body_size 20m;

#proxy_cache_path /etc/nginx/cache keys_zone=one:500m max_size=1000m;

# upstream marvin {
# server unix:/tmp/marvin/marvin.sock;
# server 127.0.0.1:8000;
# }

# types {
# text/html html htm;
# text/css css;
# application/javascript js;
# image/jpeg jpg;
# image/png png;
# }

server {
listen 80 default_server;
server_name localhost;

# location /marvin {
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# #proxy_redirect off;
# #proxy_buffering off;
# proxy_pass http://marvin:8000;
# #proxy_cache one;
# #proxy_http_version 1.1;

# #add_header 'Access-Control-Allow-Origin' '*'; # Adjust this as needed
# #add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # Adjust this as needed
# #add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; # Adjust this as needed

# # error_log /etc/nginx/marvin_error.log error;
# # access_log /etc/nginx/marvin_access.log;
# }

location / {
proxy_pass http://marvin:8000/;
#rewrite ^/marvin(/.*)$ $1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
}

location /api/ {
proxy_pass http://marvin:8000/;
#rewrite ^/marvin(/.*)$ $1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
}
# location /marvin/api {
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# #proxy_redirect off;
# #proxy_buffering off;
# proxy_pass http://marvin:8000;
# #proxy_cache one;
# #proxy_http_version 1.1;

# #add_header 'Access-Control-Allow-Origin' '*'; # Adjust this as needed
# #add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # Adjust this as needed
# #add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; # Adjust this as needed

# # error_log /etc/nginx/marvin_api_error.log error;
# # access_log /etc/nginx/marvin_api_access.log;
# }

location /marvin/static/ {
alias /usr/share/nginx/html/static/;
autoindex off;
}

location /marvin/lib/ {
alias /usr/share/nginx/html/lib/;
autoindex off;
}
}
}

0 comments on commit 07535ce

Please sign in to comment.