remove unnecessary packages

This commit is contained in:
leehk 2025-04-13 07:24:00 +08:00
parent faca3d23bb
commit e880d71960
2 changed files with 31 additions and 15 deletions

View File

@ -16,9 +16,17 @@ jobs:
contents: read
packages: write
steps:
- name: Check disk space
run: df -h
- name: Cleanup Docker resources
if: always()
run: docker system prune -a -f --volumes
run: |
docker system prune -a -f --volumes
docker volume rm $(docker volume ls -qf dangling=true) || true
docker rmi $(docker images -f "dangling=true" -q) || true
docker container prune -f
- name: Check disk space
run: df -h
- name: Checkout
uses: actions/checkout@v3
with:
@ -30,6 +38,8 @@ jobs:
- name: Pull image
run: |
docker pull ${{ env.IMAGE }}:latest || true
- name: Check disk space
run: df -h
- name: Build image
run: |
docker build \
@ -49,6 +59,8 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check disk space
run: df -h
- name: Checkout
uses: actions/checkout@v3
with:
@ -57,9 +69,14 @@ jobs:
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin ghcr.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup Docker resources
if: always()
run: docker system prune -a -f --volumes
- name: Pull image
run: |
docker pull ${{ env.IMAGE }}:latest || true
- name: Check disk space
run: df -h
- name: Build image
run: |
docker build \
@ -67,15 +84,11 @@ jobs:
--tag ${{ env.IMAGE }}:latest \
--file ./app/backend/Dockerfile.prod \
"./app/backend"
- name: Cleanup Docker resources
if: always()
run: docker system prune -a -f --volumes
- name: Run container
run: |
docker run \
-d \
--name backend \
--memory 8g \
-e PORT=8765 \
-e ENVIRONMENT=dev \
-e TESTING=0 \

View File

@ -3,7 +3,7 @@
###########
# pull official base image
FROM python:3.11-slim as builder
FROM python:3.11-alpine as builder
# set working directory
@ -15,12 +15,14 @@ ENV PYTHONUNBUFFERED=1
# install system dependencies
RUN apt-get update \
&& apt-get -y install build-essential netcat-traditional gcc \
&& apt-get clean
&& apt-get -y install build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install python dependencies
RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv
RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple && rm -rf ~/.cache/pip
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv && rm -rf ~/.cache/pip
COPY ./Pipfile .
RUN pipenv install --deploy --dev
@ -36,7 +38,7 @@ RUN pipenv run pip install black==23.12.1 flake8==7.0.0 isort==5.13.2
#########
# pull official base image
FROM python:3.11-slim
FROM python:3.11-alpine
# create directory for the app user
RUN mkdir -p /home/app
@ -59,13 +61,14 @@ ENV TESTING=0
# install system dependencies
RUN apt-get update \
&& apt-get -y install build-essential netcat-traditional gcc \
&& apt-get clean
&& apt-get -y install build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install python dependencies
COPY --from=builder /usr/src/app/Pipfile .
RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv
RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple && rm -rf ~/.cache/pip
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv && rm -rf ~/.cache/pip
RUN pipenv install --deploy --dev
RUN pipenv run pip install "uvicorn[standard]==0.26.0"