Severian commited on
Commit
a4bef0b
1 Parent(s): 6b2aef7

Update Dockerfile for correct directory structure

Browse files
Files changed (2) hide show
  1. Dockerfile +42 -33
  2. docker/entrypoint.sh +18 -0
Dockerfile CHANGED
@@ -1,37 +1,46 @@
1
- # Use an official Docker image as a base
2
- FROM docker:latest
3
 
4
- # Install Docker Compose
5
- RUN apk add --no-cache docker-compose
 
 
 
 
6
 
7
- # Set the working directory
8
  WORKDIR /app
9
 
10
- # Copy the entire project into the container
11
- COPY . .
12
-
13
- # Create necessary directories
14
- RUN mkdir -p /app/dify-main/docker
15
-
16
- # Copy configuration files
17
- RUN cp /app/docker/.env.example /app/dify-main/docker/.env && \
18
- cp /app/docker/docker-compose.yaml /app/dify-main/docker/docker-compose.yaml
19
-
20
- # Debug: List contents
21
- RUN echo "=== Listing /app contents ===" && \
22
- ls -la /app && \
23
- echo "=== Listing /app/docker contents ===" && \
24
- ls -la /app/docker && \
25
- echo "=== Listing /app/dify-main/docker contents ===" && \
26
- ls -la /app/dify-main/docker
27
-
28
- # Set environment variables for Hugging Face Spaces
29
- ENV DOCKER_DEFAULT_PLATFORM=linux/amd64
30
- ENV HF_SPACES=1
31
- ENV ENV_FILE_PATH=/app/dify-main/docker/.env
32
-
33
- # Change to the docker directory
34
- WORKDIR /app/dify-main/docker
35
-
36
- # Run Docker Compose
37
- CMD ["docker-compose", "up", "-d"]
 
 
 
 
 
 
1
+ # Use Python as base image since it's the main application runtime
2
+ FROM python:3.10-slim-bookworm
3
 
4
+ # Install required system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ curl \
7
+ nodejs \
8
+ npm \
9
+ && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Set working directory
12
  WORKDIR /app
13
 
14
+ # Copy application files
15
+ COPY api/ /app/api/
16
+ COPY web/ /app/web/
17
+
18
+ # Install Python dependencies for API
19
+ WORKDIR /app/api
20
+ RUN pip install poetry && \
21
+ poetry config virtualenvs.create false && \
22
+ poetry install --no-dev
23
+
24
+ # Install Node.js dependencies and build web frontend
25
+ WORKDIR /app/web
26
+ RUN npm install && \
27
+ npm run build
28
+
29
+ # Set environment variables
30
+ ENV FLASK_APP=app.py
31
+ ENV EDITION=SELF_HOSTED
32
+ ENV DEPLOY_ENV=PRODUCTION
33
+ ENV CONSOLE_API_URL=http://127.0.0.1:5001
34
+ ENV CONSOLE_WEB_URL=http://127.0.0.1:3000
35
+ ENV SERVICE_API_URL=http://127.0.0.1:5001
36
+ ENV APP_WEB_URL=http://127.0.0.1:3000
37
+
38
+ # Expose ports
39
+ EXPOSE 3000 5001
40
+
41
+ # Copy and setup entrypoint script
42
+ COPY docker/entrypoint.sh /entrypoint.sh
43
+ RUN chmod +x /entrypoint.sh
44
+
45
+ # Start both API and web services
46
+ CMD ["/entrypoint.sh"]
docker/entrypoint.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Start API server in background
5
+ cd /app/api
6
+ gunicorn --bind 0.0.0.0:5001 \
7
+ --workers 1 \
8
+ --worker-class gevent \
9
+ --timeout 200 \
10
+ --preload \
11
+ app:app &
12
+
13
+ # Start web server
14
+ cd /app/web
15
+ npm start
16
+
17
+ # Keep container running
18
+ wait