Skip to content
Merged
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
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
.env
node_modules
package.json
package-lock.json

# Serverless directories
.serverless

# mac
.DS_Store
venv
.venv

# JetBrains
.idea

# Python
__pycache__/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ var/
# mac
.DS_Store
venv
.venv

# JetBrains
.idea

# Python
__pycache__/
__pycache__/
52 changes: 39 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
FROM python:3.10
# ----- python-base ----- #
FROM python:3.10.11-slim-bullseye AS python-base

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_NO_INTERACTION=1

# ----- builder-base ----- #
FROM python-base AS builder-base

RUN pip install poetry==1.5.0

WORKDIR /app

COPY poetry.lock pyproject.toml ./

RUN --mount=type=cache,target=/root/.cache/poetry \
poetry install --without dev

# ----- runtime ----- #
FROM python-base AS runtime

ARG DB_HOST
ARG DB_NAME
Expand All @@ -7,19 +32,20 @@ ARG DB_PASSWORD
ARG SLACK_TOKEN
ARG SLACK_CHANNEL

ENV DB_HOST $DB_HOST
ENV DB_PORT 3306
ENV DB_NAME $DB_NAME
ENV DB_USER $DB_USER
ENV DB_PASSWORD $DB_PASSWORD
ENV SLACK_TOKEN $SLACK_TOKEN
ENV SLACK_CHANNEL $SLACK_CHANNEL
ENV DB_HOST=$DB_HOST \
DB_NAME=$DB_NAME \
DB_USER=$DB_USER \
DB_PASSWORD=$DB_PASSWORD \
SLACK_TOKEN=$SLACK_TOKEN \
SLACK_CHANNEL=$SLACK_CHANNEL \
VENV_PATH="/app/.venv"

ENV PATH="$VENV_PATH/bin:$PATH"

COPY --from=builder-base $VENV_PATH $VENV_PATH

COPY . /siksha-crawler
WORKDIR /siksha-crawler
WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY . .

CMD ["python", "handler.py"]
Loading