1. Dockerfile
FROM alpine:3.14

# This hack is widely applied to avoid python printing issues in docker containers.
# See: https://github.com/Docker-Hub-frolvlad/docker-alpine-python3/pull/13
ENV PYTHONUNBUFFERED=1

RUN apk add --no-cache curl

RUN apk add --no-cache gcc
RUN apk add --no-cache g++
RUN apk add --no-cache libxml2
RUN apk add --no-cache libxml2-dev
RUN apk add --no-cache libxslt
RUN apk add --no-cache libxslt-dev

RUN apk add --no-cache openssh-client

RUN apk add --no-cache -U tzdata

RUN echo "Asia/shanghai" >> /etc/timezone

RUN echo export LANG=zh_CN.utf8 > /etc/profile.d/locale.sh

RUN echo "**** install Python ****" && \
    apk add --no-cache python3 && \
    apk add --no-cache python3-dev && \
    if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \
    \
    echo "**** install pip ****" && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --no-cache --upgrade pip setuptools wheel bs4 requests lxml && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi

#设置语言
ENV LANG=zh_CN.UTF-8 \
    LANGUAGE=zh_CN.UTF-8
ENV TZ=Asia/Shanghai
  1. 根据系统build镜像
    docker buildx build -t bob/py --platform=local .