Spaces:
Sleeping
Sleeping
PanagiotisMark
commited on
Commit
•
3de6fea
1
Parent(s):
9c32cf4
- Added extra steps to log in to Docker Hub before actual build
Browse files- Dockerfile +42 -10
Dockerfile
CHANGED
@@ -1,11 +1,43 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
RUN useradd -m -u 1000 user
|
4 |
-
RUN chown -R user /app
|
5 |
USER user
|
6 |
ENV HOME=/home/user \
|
7 |
-
|
8 |
-
|
9 |
|
10 |
# Set the working directory in the container
|
11 |
WORKDIR /app/src
|
@@ -14,10 +46,10 @@ WORKDIR /app/src
|
|
14 |
EXPOSE 7860
|
15 |
|
16 |
ENV PYTHONUNBUFFERED=1 \
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
# Run app.py when the container launches
|
23 |
-
CMD ["python", "-m", "claim_analysis.server.gradio_app"]
|
|
|
1 |
+
# Stage 1: Install Docker CLI and log in to Docker Hub
|
2 |
+
FROM ubuntu:20.04 AS docker-login
|
3 |
+
|
4 |
+
# Define build arguments for secrets
|
5 |
+
ARG DOCKER_HUB_USERNAME
|
6 |
+
ARG DOCKER_HUB_PASSWORD
|
7 |
+
|
8 |
+
# Install Docker CLI
|
9 |
+
RUN apt-get update && apt-get install -y docker.io
|
10 |
+
|
11 |
+
# Create a script to log in to Docker Hub
|
12 |
+
RUN echo "#!/bin/sh\n\
|
13 |
+
echo \$DOCKER_HUB_PASSWORD | docker login -u \$DOCKER_HUB_USERNAME --password-stdin" > /docker-login.sh && \
|
14 |
+
chmod +x /docker-login.sh
|
15 |
+
|
16 |
+
# Run the script to log in to Docker Hub
|
17 |
+
RUN --mount=type=secret,id=DOCKER_HUB_USERNAME \
|
18 |
+
--mount=type=secret,id=DOCKER_HUB_PASSWORD \
|
19 |
+
/docker-login.sh
|
20 |
+
|
21 |
+
# Stage 2: Use authenticated session to pull the base image and build the application
|
22 |
+
FROM intelligencenoborders/inobo:scinobo-claim-verification AS base
|
23 |
+
|
24 |
+
# Define build arguments for secrets (needed to pass the build context)
|
25 |
+
ARG DOCKER_HUB_USERNAME
|
26 |
+
ARG DOCKER_HUB_PASSWORD
|
27 |
+
|
28 |
+
# Install Docker CLI in the base image
|
29 |
+
RUN apt-get update && apt-get install -y docker.io
|
30 |
+
|
31 |
+
# Copy the Docker config from the first stage
|
32 |
+
COPY --from=docker-login /root/.docker /root/.docker
|
33 |
+
|
34 |
+
# Create user and set environment variables
|
35 |
+
RUN useradd -m -u 1000 user && \
|
36 |
+
chown -R user /app
|
37 |
|
|
|
|
|
38 |
USER user
|
39 |
ENV HOME=/home/user \
|
40 |
+
PATH=/home/user/.local/bin:$PATH
|
|
|
41 |
|
42 |
# Set the working directory in the container
|
43 |
WORKDIR /app/src
|
|
|
46 |
EXPOSE 7860
|
47 |
|
48 |
ENV PYTHONUNBUFFERED=1 \
|
49 |
+
GRADIO_ALLOW_FLAGGING=never \
|
50 |
+
GRADIO_NUM_PORTS=1 \
|
51 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
52 |
+
SYSTEM=spaces
|
53 |
|
54 |
# Run app.py when the container launches
|
55 |
+
CMD ["python", "-m", "claim_analysis.server.gradio_app"]
|