Skip to content

Commit

Permalink
Create a production Dockerfile #28
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 2, 2024
1 parent c2c505b commit 1756dff
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM python:3.10-alpine3.19

WORKDIR /ldap-jwt-auth-run

COPY README.md pyproject.toml ./
# Copy ldap_jwt_auth source files
COPY ldap_jwt_auth/ ldap_jwt_auth/
COPY logs/ logs/

RUN set -eux; \
\
# Install python-ldap system dependencies \
apk add --no-cache build-base openldap-dev python3-dev; \
\
# Install pip dependencies \
python -m pip install --no-cache-dir .; \
\
# Create loging.ini from its .example file \
cp ldap_jwt_auth/logging.example.ini ldap_jwt_auth/logging.ini; \
\
# Create a non-root user to run as \
addgroup -S ldap-jwt-auth; \
adduser -S -D -G ldap-jwt-auth -H -h /ldap-jwt-auth-run ldap-jwt-auth; \
\
# Change ownership of logs/ - app will need to write log files to it \
chown -R ldap-jwt-auth:ldap-jwt-auth logs/

USER ldap-jwt-auth

ENV API__TITLE="LDAP-JWT Authentication Service API"
ENV API__DESCRIPTION="This is the API for the LDAP-JWT Authentication Service"
ENV API__ROOT_PATH=""
ENV AUTHENTICATION__PRIVATE_KEY_PATH="./keys/jwt-key"
ENV AUTHENTICATION__PUBLIC_KEY_PATH="./keys/jwt-key.pub"
ENV AUTHENTICATION__JWT_ALGORITHM="RS256"
ENV AUTHENTICATION__ACCESS_TOKEN_VALIDITY_MINUTES=5
ENV AUTHENTICATION__REFRESH_TOKEN_VALIDITY_DAYS=7
ENV AUTHENTICATION__ACTIVE_USERNAMES_PATH="./active_usernames.txt"
ENV LDAP_SERVER__URL="ldap://ldap.example.com:389"
ENV LDAP_SERVER__REALM="LDAP.EXAMPLE.COM"

CMD ["uvicorn", "ldap_jwt_auth.main:app", "--host", "0.0.0.0", "--port", "8000"]
EXPOSE 8000

0 comments on commit 1756dff

Please sign in to comment.