Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds dockerfile and docker compose #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.db
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docker_build:
@docker compose up --no-start slackbot-ai

docker_start_all: docker_build
@docker compose start slackbot-ai

docker_stop_all:
@docker compose stop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could not find a place to hook this on, but maybe add *.db into .dockerignore like it is on .gitignore? the reasoning for this is that it's mapped as a volume, but building and pushing an image from your machine is going to send the sqlite db along the image.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a dockerignore with the .db exclusion to be on the safe side.

15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
slackbot-ai:
container_name: slack-bot-ai
image: slackbot-ai:latest
build: .
ports:
- "${PORT:-7999}:${PORT:-7999}"
- "${DEBUG_PORT:-3000}:${DEBUG_PORT:-3000}"
env_file: .env
tty: true
stdin_open: true
volumes:
- type: bind
source: .
target: /app/
31 changes: 31 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.10-slim AS base

ENV LANG C.UTF-8
ENV PYTHONUNBUFFERED 1

RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
build-essential \
tzdata \
git \
libatlas-base-dev\
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
pip install --no-cache-dir poetry==1.8.3 setuptools && poetry config virtualenvs.create false


RUN pip install --upgrade pip && pip install --no-cache-dir poetry gunicorn uvicorn && poetry config virtualenvs.create false


FROM base AS install

WORKDIR /app
COPY pyproject.toml poetry.lock /app/
RUN poetry install --no-dev

FROM install AS runtime
COPY . /app/

ENV PORT=7999

ENTRYPOINT ["sh", "-c", "uvicorn project.api:app --host 0.0.0.0 --port $PORT --reload"]