-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cef3454
commit 5487491
Showing
7 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging | ||
import sys | ||
|
||
LOG_LEVELS = { | ||
"CRITICAL": logging.CRITICAL, | ||
"ERROR": logging.ERROR, | ||
"WARNING": logging.WARNING, | ||
"INFO": logging.INFO, | ||
"DEBUG": logging.DEBUG, | ||
} | ||
|
||
|
||
# this is suboptimal but python has no public mapping of log names to levels | ||
|
||
|
||
def setup_logging(log_level: int = logging.INFO): | ||
"""Helper function to setup logging to console. | ||
:param log_level: Log level to use when logging | ||
""" | ||
root_logger = logging.getLogger("") # root logger | ||
formatter = logging.Formatter("[%(levelname)s] %(asctime)s %(name)s(%(lineno)s): %(message)s") | ||
stream_handler = logging.StreamHandler(sys.stdout) | ||
stream_handler.setFormatter(formatter) | ||
if not len(root_logger.handlers): | ||
# assumes we have already been set up. | ||
root_logger.addHandler(stream_handler) | ||
root_logger.setLevel(log_level) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.11-slim | ||
|
||
# Set environment variables | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /app | ||
|
||
# Install dependencies and git | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
nginx \ | ||
&& apt-get clean | ||
|
||
# Install the dependencies | ||
# TODO -- use the right version | ||
#RUN pip install "git+https://github.com/dagworks-inc/burr.git@tracker-s3#egg=burr[tracking-server-s3]" | ||
RUN pip install "burr[tracking-server-s3]==0.26.0rc4" | ||
|
||
# Copy the nginx config file | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Expose the port FastAPI will run on and the port NGINX will listen to | ||
EXPOSE 8000 | ||
EXPOSE 80 | ||
|
||
ENV BURR_S3_BUCKET=burr-prod-test | ||
ENV BURR_load_snapshot_on_start=True | ||
ENV BURR_snapshot_interval_milliseconds=3_600_000 | ||
ENV BURR_BACKEND_IMPL=s3 | ||
ENV ENV DEBIAN_FRONTEND=noninteractive | ||
ENV BURR_BACKEND_IMPL=burr.tracking.server.s3.backend.SQLiteS3Backend | ||
|
||
|
||
# Command to run FastAPI server and NGINX | ||
CMD ["sh", "-c", "uvicorn burr.tracking.server.run:app --host 0.0.0.0 --port 8000 & nginx -g 'daemon off;'"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
server { | ||
listen 80; | ||
|
||
location / { | ||
proxy_pass http://127.0.0.1:8000; | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters