-
Notifications
You must be signed in to change notification settings - Fork 29
/
Dockerfile
37 lines (30 loc) · 1.03 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Image for a Python 3 development environment
FROM python:3.11-slim
# Add any tools that are needed beyond Python 3.9
RUN apt-get update \
&& apt-get install -y sudo git make zip tree curl wget jq \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Create a user for development
ARG USERNAME=devops
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user with passwordless sudo privileges
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
&& usermod -aG sudo $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Set up the Python development environment
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN python -m pip install -U pip poetry && \
poetry config virtualenvs.create false && \
poetry install
ENV PORT 8080
EXPOSE $PORT
# Enable color terminal for docker exec bash
ENV TERM=xterm-256color
# Become a regular user
USER $USERNAME