Created
March 11, 2025 04:03
-
-
Save robobe/4b86c784f19985a0283903bd54d36d4c to your computer and use it in GitHub Desktop.
dockerfile to build python packages on ARM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM arm64v8/ubuntu:20.04 | |
RUN apt-get update \ | |
&& apt-get -y install --no-install-recommends \ | |
python3 \ | |
python3-pip \ | |
python3-venv \ | |
python-is-python3 \ | |
&& apt-get autoremove -y \ | |
&& apt-get clean -y \ | |
&& rm -rf /var/lib/apt/lists/* | |
ARG USERNAME=user | |
ARG USER_UID=1000 | |
ARG USER_GID=$USER_UID | |
# Create a non-root user | |
RUN groupadd --gid $USER_GID $USERNAME \ | |
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ | |
# Add sudo support for the non-root user | |
&& apt-get update \ | |
&& apt-get install -y sudo \ | |
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ | |
&& chmod 0440 /etc/sudoers.d/$USERNAME \ | |
&& rm -rf /var/lib/apt/lists/* | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install timezone | |
RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime \ | |
&& export DEBIAN_FRONTEND=noninteractive \ | |
&& apt-get update \ | |
&& apt-get install -y tzdata \ | |
&& dpkg-reconfigure --frontend noninteractive tzdata \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN apt-get update \ | |
&& apt-get -y install --no-install-recommends \ | |
dh-python \ | |
python3-all \ | |
python3-pip \ | |
python3-venv \ | |
debhelper \ | |
&& apt-get autoremove -y \ | |
&& apt-get clean -y \ | |
&& rm -rf /var/lib/apt/lists/* | |
COPY requirements.txt /tmp/pip-tmp/ | |
RUN pip3 install --no-cache-dir -r /tmp/pip-tmp/requirements.txt \ | |
&& rm -rf /tmp/pip-tmp | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment