-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpython-slim-buster.Dockerfile
60 lines (47 loc) · 2.19 KB
/
python-slim-buster.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# syntax = edrevo/dockerfile-plus
# SPDX-FileCopyrightText: 2014 SAP SE Srdjan Boskovic <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#
# Build:
# docker build --platform=linux/amd64 -t python-311-slim-buster -f python-311-slim-buster.Dockerfile .
# docker run --platform=linux/amd64 -it --name python-311-slim-buster -v /Users/d037732/SAPDevelop/dev:/home/www-admin/src python-311-slim-buster /bin/bash --login
#
# Run:
# docker start -ai python-311-slim-buster
#
FROM python:3.11-slim-buster
ARG adminuser=www-admin
ARG dev_python="pip wheel pytest cython ipython"
ARG dev_tools="sudo curl wget git unzip vim tree tmux iproute2 iputils-ping"
ARG dev_libs="build-essential make libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev"
ENV container docker
# os update and packages
USER root
RUN \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt update && DEBIAN_FRONTEND=noninteractive apt install -y locales ${dev_tools} ${dev_libs} && rm -rf /var/lib/apt/lists/*
# timezone # https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
ENV TZ=Europe/Berlin
RUN locale-gen de_DE && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# https://daten-und-bass.io/blog/fixing-missing-locale-setting-in-ubuntu-docker-image/
RUN \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
# admin user
adduser --disabled-password --gecos "" ${adminuser} && \
usermod -aG www-data,sudo ${adminuser} && \
echo "${adminuser} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
# cleanup
rm -rf /tmp/*
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# sap binaries
INCLUDE+ common/saplibs.Dockerfile
# work user
USER ${adminuser}
WORKDIR /home/${adminuser}
RUN printf "alias e=exit\nalias ..=cd..\nalias :q=exit\nalias ll='ls -l'\nalias la='ls -la'\nalias distro='cat /etc/*-release'\n" > .bash_aliases && \
printf "\n# colors\nexport TERM=xterm-256color\n" >> .bashrc && \
printf "\nexport PATH=/home/${adminuser}/.local/bin:$PATH\n" >> .bashrc