obsidian_flow / Dockerfile
thinh-vu's picture
Create Dockerfile
7ff9d0a verified
Raw
History Blame Contribute Delete
1.36 kB
# Builder stage
FROM python:3.10-slim as builder
WORKDIR /build
# Install git
RUN apt-get update && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/*
# Arguments for secrets
ARG GIT_USR
ARG GIT_TK
ARG PRV_REPO
# Clone the private repository using secrets
RUN --mount=type=secret,id=GIT_USR,mode=0444,required=true \
--mount=type=secret,id=GIT_TK,mode=0444,required=true \
--mount=type=secret,id=PRV_REPO,mode=0444,required=true \
git clone https://$(cat /run/secrets/GIT_USR):$(cat /run/secrets/GIT_TK)@github.com/$(cat /run/secrets/GIT_USR)/$(cat /run/secrets/PRV_REPO) .
RUN ls -la
# Final stage
FROM python:3.10-slim
# Install git in the final image
RUN apt-get update && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/*
# Add user and set up environment
RUN useradd -m vnstock
USER vnstock
WORKDIR /usr/src/app
# Copy the cloned repository from the builder stage
COPY --from=builder /build/PRV_REPO .
RUN ls -la
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Install additional Python packages
RUN pip install --no-cache-dir flask-jwt-extended flask-security
# Set PATH environment variable
ENV PATH="/home/vnstock/.local/bin:${PATH}"
# Expose the application port
EXPOSE 7860
# Command to run the application
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]