forked from ucbepic/docetl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ucbepic:main' into main
- Loading branch information
Showing
60 changed files
with
7,135 additions
and
1,751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Docker CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
docker-build-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Remove unnecessary files | ||
run: | | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | ||
- uses: actions/checkout@v4 | ||
- name: Remove .env copy from Dockerfile | ||
run: sed -i '/COPY .env/d' Dockerfile | ||
|
||
- name: Build Docker image | ||
run: docker build -t docetl . | ||
|
||
- name: Create Docker volume | ||
run: docker volume create docetl-data | ||
|
||
- name: Test Docker container | ||
run: | | ||
# Run the container in detached mode | ||
docker run -d \ | ||
-p 3000:3000 \ | ||
-p 8000:8000 \ | ||
-v docetl-data:/docetl-data \ | ||
-e FRONTEND_HOST=0.0.0.0 \ | ||
-e FRONTEND_PORT=3000 \ | ||
-e BACKEND_HOST=0.0.0.0 \ | ||
-e BACKEND_PORT=8000 \ | ||
--name docetl-test \ | ||
docetl | ||
# Wait for container to start up | ||
sleep 120 | ||
# Check if container is still running | ||
if [ "$(docker ps -q -f name=docetl-test)" ]; then | ||
echo "Container is running successfully" | ||
else | ||
echo "Container failed to stay running" | ||
docker logs docetl-test | ||
exit 1 | ||
fi | ||
# Cleanup | ||
docker stop docetl-test | ||
docker rm docetl-test | ||
- name: Clean up Docker volume | ||
run: docker volume rm docetl-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Build stage for Python dependencies | ||
FROM python:3.11-slim AS python-builder | ||
|
||
RUN pip install poetry==1.4.2 | ||
|
||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache \ | ||
DOCETL_HOME_DIR="/docetl-data" | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
COPY docetl/ ./docetl/ | ||
COPY server/ ./server/ | ||
COPY tests/ ./tests/ | ||
RUN touch README.md | ||
|
||
# Install with --no-root first for dependencies, then install with root for entrypoints | ||
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --all-extras --no-root && \ | ||
poetry install --all-extras | ||
|
||
# Build stage for Node.js dependencies | ||
FROM node:20-alpine AS node-builder | ||
|
||
WORKDIR /app/website | ||
|
||
# Update DOCETL_HOME_DIR to match final location | ||
ENV DOCETL_HOME_DIR="/docetl-data" | ||
|
||
COPY website/package*.json ./ | ||
RUN npm install | ||
COPY website/ ./ | ||
RUN npm run build | ||
|
||
# Final runtime stage | ||
FROM python:3.11-slim AS runtime | ||
|
||
# Install Node.js | ||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | ||
&& apt-get install -y nodejs \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
# Copy Python virtual environment from builder | ||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" \ | ||
PYTHONPATH="/app" \ | ||
DOCETL_HOME_DIR="/docetl-data" | ||
|
||
COPY --from=python-builder /app/.venv ${VIRTUAL_ENV} | ||
|
||
# Copy Python application files | ||
COPY docetl/ ./docetl/ | ||
COPY server/ ./server/ | ||
COPY tests/ ./tests/ | ||
COPY pyproject.toml poetry.lock ./ | ||
COPY .env ./ | ||
|
||
# Copy Node.js dependencies and application files | ||
COPY --from=node-builder /app/website ./website | ||
|
||
ENV PORT=3000 | ||
|
||
# Create data directory with appropriate permissions | ||
RUN mkdir -p /docetl-data && chown -R nobody:nogroup /docetl-data && chmod 777 /docetl-data | ||
|
||
# Define volume AFTER creating and setting permissions | ||
VOLUME ["/docetl-data"] | ||
|
||
# Expose ports for frontend and backend | ||
EXPOSE 3000 8000 | ||
|
||
# Start both servers | ||
CMD ["sh", "-c", "python3 server/app/main.py & cd website && npm run start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.