以下是Dockerfile,
FROM alpine:3.10
# Add the testing repo in case it's needed for additional dependencies
# For example, gdal can be installed by using gdal@community
RUN echo "@community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# Install system dependencies
RUN apk add --no-cache --update \
bash \
gcc \
build-base \
musl-dev \
postgresql-dev \
'python3~=3.7.5' \
'python3-dev~=3.7.5' \
curl \
# zlib, zlib-dev, and libjpeg-turbo are required by pillow
zlib \
zlib-dev \
libjpeg-turbo \
libjpeg-turbo-dev \
libffi-dev
RUN pip3 install --no-cache-dir -q pipenv
# Add our code
ADD ./ /opt/webapp/
WORKDIR /opt/webapp
# Install dependencies
RUN pipenv install --deploy --system
# Allow SECRET_KEY to be passed via arg so collectstatic can run during build time
ARG SECRET_KEY
RUN python3 manage.py collectstatic --no-input
# Run the image as a non-root user
RUN adduser -D myuser
USER myuser
# Run the web server on port $PORT
CMD waitress-serve --port=$PORT performit_15391.wsgi:application
以下是记录的来自服务器的日志,我不知道为什么构建失败,有人可以指导吗?
=== Fetching app code.
=== Building release (./backend/Dockerfile)
Sending build context to Docker daemon 895kB
Step 1/12 : FROM alpine:3.10
3.10: Pulling from library/alpine
21c83c524219: Pulling fs layer
21c83c524219: Verifying Checksum
21c83c524219: Download complete
21c83c524219: Pull complete
Digest: sha256:f0e9534a598e501320957059cb2a23774b4d4072e37c7b2cf7e95b241f019e35
Status: Downloaded newer image for alpine:3.10
---> be4e4bea2c2e
Step 2/12 : RUN echo "@community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
---> Running in 42057b30f8bf
Removing intermediate container 42057b30f8bf
---> 015ada914599
Step 3/12 : RUN apk add --no-cache --update bash gcc build-base musl-dev postgresql-dev 'python3~=3.7.5' 'python3-dev~=3.7.5' curl zlib zlib-dev libjpeg-turbo libjpeg-turbo-dev libffi-dev
---> Running in acf5e541c616
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
[91mERROR: unsatisfiable constraints:
[0m python3-3.7.7-r0:
breaks: world[python3~3.7.5]
satisfies: python3-dev-3.7.7-r0[python3=3.7.7-r0]
python3-dev-3.7.7-r0:
breaks: world[python3-dev~3.7.5]
The command '/bin/sh -c apk add --no-cache --update bash gcc build-base musl-dev postgresql-dev 'python3~=3.7.5' 'python3-dev~=3.7.5' curl zlib zlib-dev libjpeg-turbo libjpeg-turbo-dev libffi-dev' returned a non-zero code: 2
以上是日志,apk命令失败。有依赖性问题吗?对我来说,日志消息不是很有用。预先感谢。
答案 0 :(得分:3)
安装Python时存在版本冲突。 APK软件包管理器支持python-3.7.7-r0
的{{1}}。但是您已经明确提到alpine:3.10
版本,该版本不可用。在这里,您可以使用python 3.7.7或使用具有python 3.7.5的基本映像来构建您的应用。