Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +10 -28
Dockerfile
CHANGED
|
@@ -1,48 +1,30 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
-
# Base Python Image
|
| 4 |
FROM python:3.12
|
| 5 |
|
| 6 |
-
# Set environment variables
|
| 7 |
ENV PYTHONDONTWRITEBYTECODE 1
|
| 8 |
ENV PYTHONUNBUFFERED 1
|
| 9 |
|
| 10 |
-
# Install required OS packages
|
| 11 |
RUN apt-get update && apt-get install -y \
|
| 12 |
git openssh-client && \
|
| 13 |
rm -rf /var/lib/apt/lists/*
|
| 14 |
-
|
| 15 |
|
| 16 |
-
# Set work directory
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
mkdir -p /root/.ssh && \
|
| 24 |
-
file /run/secrets/SSH_PRIVATE_KEY && \
|
| 25 |
-
od -c /run/secrets/SSH_PRIVATE_KEY && \
|
| 26 |
-
|
| 27 |
-
cp /run/secrets/SSH_PRIVATE_KEY /root/.ssh/id_rsa && \
|
| 28 |
-
chmod 600 /root/.ssh/id_rsa && \
|
| 29 |
-
ssh-keyscan github.com >> /root/.ssh/known_hosts && \
|
| 30 |
-
git clone --branch coolify --single-branch git@github.com:Fvt-second/Giftx_api.git /app
|
| 31 |
-
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
ARG GITHUB_BRANCH=coolify
|
| 36 |
-
RUN echo "Repo: ${GITHUB_REPO}" && echo "Branch: ${GITHUB_BRANCH}"
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
# Install
|
| 41 |
RUN pip install --upgrade pip
|
| 42 |
RUN if [ -f "requirements.txt" ]; then pip install -r requirements.txt; fi
|
| 43 |
|
| 44 |
-
# Expose Hugging Face Spaces default port
|
| 45 |
EXPOSE 7860
|
| 46 |
|
| 47 |
-
# Run FastAPI with Uvicorn
|
| 48 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1.4
|
|
|
|
|
|
|
| 2 |
FROM python:3.12
|
| 3 |
|
|
|
|
| 4 |
ENV PYTHONDONTWRITEBYTECODE 1
|
| 5 |
ENV PYTHONUNBUFFERED 1
|
| 6 |
|
|
|
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
git openssh-client && \
|
| 9 |
rm -rf /var/lib/apt/lists/*
|
|
|
|
| 10 |
|
|
|
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
+
# Generate SSH key (for testing/development)
|
| 14 |
+
RUN ssh-keygen -t ed25519 -N "" -f /root/.ssh/id_ed25519 && \
|
| 15 |
+
echo "Public key (add this to GitHub deploy keys!):" && \
|
| 16 |
+
cat /root/.ssh/id_ed25519.pub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
# Add GitHub to known_hosts
|
| 19 |
+
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
# Clone repo (this will fail until you manually add the public key to GitHub)
|
| 22 |
+
RUN git clone --branch coolify --single-branch git@github.com:Fvt-second/Giftx_api.git /app || echo "Add the public key to GitHub to enable cloning"
|
| 23 |
|
| 24 |
+
# Install dependencies (this will fail if clone didn't work)
|
| 25 |
RUN pip install --upgrade pip
|
| 26 |
RUN if [ -f "requirements.txt" ]; then pip install -r requirements.txt; fi
|
| 27 |
|
|
|
|
| 28 |
EXPOSE 7860
|
| 29 |
|
|
|
|
| 30 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
|