1) apply multi stage build, 2) rm gemini
This commit is contained in:
40
Dockerfile
40
Dockerfile
@ -1,29 +1,25 @@
|
||||
FROM python:3.13-slim
|
||||
# Stage1
|
||||
FROM python:3.13-slim-bullseye AS builder
|
||||
|
||||
# Set timezone
|
||||
ARG WTH
|
||||
ENV WTH=$WTH
|
||||
ENV TZ="Asia/Taipei"
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# Init workspace
|
||||
RUN mkdir -p /app
|
||||
RUN apt update && apt install -y curl
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
RUN poetry config virtualenvs.create false
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
RUN poetry install --with main
|
||||
|
||||
# Install dependencies
|
||||
# Poetry exportation cmd: poetry export --without-hashes --without dev -f requirements.txt -o requirements.tx
|
||||
COPY ./requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
# Stage2
|
||||
FROM python:3.13-slim-bullseye AS final
|
||||
|
||||
# Copy source copy
|
||||
ENV TZ="Asia/Taipei"
|
||||
RUN apt update && apt install -y curl
|
||||
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
|
||||
WORKDIR /app
|
||||
COPY ./translator .
|
||||
|
||||
# Install tools
|
||||
RUN apt update
|
||||
RUN apt install -y curl
|
||||
|
||||
# Run app
|
||||
CMD streamlit run app.py --server.port=8501 --server.enableCORS=false --server.enableXsrfProtection=false
|
||||
EXPOSE 8501
|
||||
CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port=8501", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]
|
||||
|
||||
# Build
|
||||
# docker build -t translator:latest .
|
||||
# docker build --platform=linux/amd64 -t translator:latest .
|
||||
# docker save -o translator.tar translator:latest
|
Reference in New Issue
Block a user