Skip to content
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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
.coverage
.DS_Store
.env
.git/
.pytest_cache/
node_modules/
static/
*.db
*.egg-info
*.log
*.mo
**/__pycache__/
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SLACK_APP_TOKEN=
SLACK_BOT_TOKEN=
55 changes: 55 additions & 0 deletions appcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM python:3.14-alpine

# install system packages that don't come preinstalled on Alpine
RUN apk add bash

# declare default build args for later stages
ARG USER=compiler \
USER_UID=1000 \
GROUP=appgroup \
GROUP_GID=1000

# set env vars for the user, including HOME
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HOME=/home/${USER} \
USER=${USER} \
PATH="/${USER}/.local/bin:$PATH" \
# update env for local pip installs
# see https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUSERBASE
# since all `pip install` commands are in the context of $USER
# $PYTHONUSERBASE is the location used by default
PYTHONUSERBASE="/${USER}/.local" \
# where to store the pip cache
# https://pip.pypa.io/en/stable/cli/pip/#cmdoption-cache-dir
PIP_CACHE_DIR="/${USER}/.cache/pip"

# create non-root $USER
RUN addgroup --gid ${GROUP_GID} ${GROUP} && \
adduser --uid ${USER_UID} --ingroup ${GROUP} --shell /bin/bash --disabled-password ${USER}

# create directories and set permissions
RUN mkdir -p /$USER/app && \
chown -R ${USER}:${GROUP} /${USER} && \
# pip cache dir must be created and owned by the user to work with BuildKit cache
mkdir -p ${PIP_CACHE_DIR} && \
# own the parent directory of PIP_CACHE_DIR
chown -R ${USER}:${GROUP} /${USER}/.cache

# switch to non-root $USER
USER $USER

# enter app directory
WORKDIR /$USER/app

# copy app code into image
COPY slackronyms .

# install python dependencies
RUN --mount=type=cache,id=pipcache,target=${PIP_CACHE_DIR},uid=${USER_UID},gid=${GROUP_GID} \
python -m pip install --user --upgrade pip && \
pip install --user -r requirements.txt

# configure container executable
ENTRYPOINT ["/bin/bash"]
CMD ["-c", "python ./app.py"]
9 changes: 8 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: template-devcontainer
name: slackronyms

services:
app:
build:
context: .
dockerfile: appcontainer/Dockerfile
image: slackronyms:latest
env_file: .env

dev:
build:
context: .
Expand Down