From ddce943c33a0e1f5f0fef7166bbd2b895f8adbb7 Mon Sep 17 00:00:00 2001 From: tradewind Date: Tue, 12 Jul 2022 15:30:48 +0800 Subject: [PATCH] #tradewind:update --- docker-compose.yml | 15 +++++++++++++-- php7.4/dockerfile | 1 + php7.4/sources.list | 20 ++++++++++---------- python/dockerfile | 24 ++++++++++++++++++++++++ python/requirements.txt | 6 ++++++ 5 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 python/dockerfile create mode 100644 python/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml index a084b9b..a7c07b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - ./log/nginx:/var/log/nginx container_name: nginx restart: always - php7.4: + php74: build: context: ./php7.4/ dockerfile: dockerfile @@ -37,7 +37,7 @@ services: environment: MYSQL_ROOT_PASSWORD: root command: --default-authentication-plugin=mysql_native_password -# platform: linux/x86_64 # apple silicon +# platform: linux/amd64 # apple silicon networks: - server ports: @@ -55,5 +55,16 @@ services: ports: - 6379:6379 container_name: redis + python: + build: + context: ./ + dockerfile: dockerfile + volumes: + - ${LOCAL_CODE_ROOT}:/code + networks: + - server + container_name: python + ports: + - 8000:8000 networks: server: \ No newline at end of file diff --git a/php7.4/dockerfile b/php7.4/dockerfile index 3a94cc6..4405908 100644 --- a/php7.4/dockerfile +++ b/php7.4/dockerfile @@ -3,6 +3,7 @@ FROM php:7.4-fpm RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list RUN apt-get update && apt-get install -y \ + git \ zip \ unzip \ libpq-dev \ diff --git a/php7.4/sources.list b/php7.4/sources.list index 8fbb4a9..e0d1a18 100644 --- a/php7.4/sources.list +++ b/php7.4/sources.list @@ -1,10 +1,10 @@ -deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse -deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse -deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse -deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse -deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse -deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse \ No newline at end of file +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free +# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free +# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free + +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free +# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free + +deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free +# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free \ No newline at end of file diff --git a/python/dockerfile b/python/dockerfile new file mode 100644 index 0000000..d18d896 --- /dev/null +++ b/python/dockerfile @@ -0,0 +1,24 @@ +FROM python:3.9-alpine3.13 as build +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \ + && apk update \ + && apk add git gcc g++ musl-dev libffi-dev libressl-dev make +WORKDIR /install +COPY requirements.txt /install/requirements.txt +RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r /install/requirements.txt \ + && mkdir -p /install/lib/python3.9/site-packages \ + && cp -rp /usr/local/lib/python3.9/site-packages /install/lib/python3.9 \ + && cp -p /usr/local/bin/uvicorn /install/uvicorn + + +FROM python:3.9-alpine3.13 + +# 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 + +COPY --from=build /install/lib /usr/local/lib +COPY --from=build /install/uvicorn /usr/local/bin/uvicorn + +WORKDIR /code + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..acfa73b --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,6 @@ +fastapi +python-multipart +python_jose[cryptography] +SQLAlchemy[sqlite] +uvicorn[standard] +passlib[bcrypt]