diff --git a/ui/deployment/Dockerfile.backend b/ui/backend/Dockerfile.backend similarity index 81% rename from ui/deployment/Dockerfile.backend rename to ui/backend/Dockerfile.backend index 11174f2b0..5abdafb11 100644 --- a/ui/deployment/Dockerfile.backend +++ b/ui/backend/Dockerfile.backend @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \ libffi-dev \ && rm -rf /var/lib/apt/lists/* -COPY backend/server/requirements.txt /code/ +COPY server/requirements.txt /code/ RUN pip install -r /code/requirements.txt -COPY ./backend /code/ +COPY . /code/ diff --git a/ui/deployment/Dockerfile.backend-prod b/ui/backend/Dockerfile.backend-prod similarity index 76% rename from ui/deployment/Dockerfile.backend-prod rename to ui/backend/Dockerfile.backend-prod index 98f913852..4107dd8cb 100644 --- a/ui/deployment/Dockerfile.backend-prod +++ b/ui/backend/Dockerfile.backend-prod @@ -12,9 +12,9 @@ RUN apt-get update && apt-get install -y \ libffi-dev \ && rm -rf /var/lib/apt/lists/* -COPY backend/ /code/ -COPY backend/server/requirements.txt /code/ +COPY . /code/ +COPY server/requirements.txt /code/ RUN pip install -r /code/requirements.txt -COPY ./backend /code/ +COPY . /code/ diff --git a/ui/deployment/README.md b/ui/deployment/README.md deleted file mode 100644 index 9d6add108..000000000 --- a/ui/deployment/README.md +++ /dev/null @@ -1,19 +0,0 @@ - - - -# Build caveats - -## You need 9GB assigned to Docker or more to build the frontend -The frontend build requires around 8GB of memory to be assigned to docker to build. -If you run into this, bump your docker memory allocation up to 9GB or more. - -How to push to docker hub: -```bash -docker tag local-image:tagname dagworks/ui-backend:LATEST -docker push dagworks/ui-backend:LATEST -``` - -```bash -docker tag local-image:tagname dagworks/ui-frontend:LATEST -docker push dagworks/ui-frontend:LATEST -``` diff --git a/ui/deployment/dev.sh b/ui/deployment/dev.sh deleted file mode 100755 index 67d8c9055..000000000 --- a/ui/deployment/dev.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Find the git root directory dynamically -GIT_ROOT=$(git rev-parse --show-toplevel) - -# Check if --build parameter is passed -if [[ $1 == "--build" ]]; then - # Run docker-compose up with project directory, verbose mode and build - docker-compose --verbose --project-directory "$GIT_ROOT/ui" -f "$GIT_ROOT/ui/deployment/docker-compose.yml" up --build -else - # Run docker-compose up with project directory and verbose mode - docker-compose --verbose --project-directory "$GIT_ROOT/ui" -f "$GIT_ROOT/ui/deployment/docker-compose.yml" up -fi diff --git a/ui/deployment/run.sh b/ui/deployment/run.sh deleted file mode 100755 index 534c7bab7..000000000 --- a/ui/deployment/run.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Find the git root directory dynamically -GIT_ROOT=$(git rev-parse --show-toplevel) - -# Check if --build parameter is passed -if [[ $1 == "--build" ]]; then - # Run docker-compose up with project directory, verbose mode and build - docker-compose --verbose --project-directory "$GIT_ROOT/ui" -f "$GIT_ROOT/ui/deployment/docker-compose-prod.yml" up --build -else - # Run docker-compose up with project directory and verbose mode - docker-compose --verbose --project-directory "$GIT_ROOT/ui" -f "$GIT_ROOT/ui/deployment/docker-compose-prod.yml" up -fi diff --git a/ui/deployment/stop.sh b/ui/deployment/stop.sh deleted file mode 100755 index d93eb6e0d..000000000 --- a/ui/deployment/stop.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Find the git root directory dynamically -GIT_ROOT=$(git rev-parse --show-toplevel) - -# Run docker-compose up with project directory and verbose mode -docker-compose --verbose --project-directory "$GIT_ROOT/ui" -f "$GIT_ROOT/ui/deployment/docker-compose.yml" down diff --git a/ui/dev.sh b/ui/dev.sh new file mode 100755 index 000000000..445fd1681 --- /dev/null +++ b/ui/dev.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Check if --build parameter is passed +if [[ $1 == "--build" ]]; then + # Run docker-compose up with project directory, verbose mode and build + docker-compose --verbose -f docker-compose.yml up --build +else + # Run docker-compose up with project directory and verbose mode + docker-compose --verbose -f docker-compose.yml up +fi diff --git a/ui/deployment/docker-compose-prod.yml b/ui/docker-compose-prod.yml similarity index 89% rename from ui/deployment/docker-compose-prod.yml rename to ui/docker-compose-prod.yml index c62d3e022..90e38a781 100644 --- a/ui/deployment/docker-compose-prod.yml +++ b/ui/docker-compose-prod.yml @@ -17,10 +17,11 @@ services: retries: 5 backend: + container_name: ui-backend image: dagworks/ui-backend:latest build: - context: ./ - dockerfile: deployment/Dockerfile.backend-prod + context: backend + dockerfile: Dockerfile.backend-prod entrypoint: ["/bin/bash", "-c", "cd /code/server && ls && ./entrypoint.sh"] ports: - "8241:8241" @@ -42,10 +43,11 @@ services: - backend_data:/data/ frontend: + container_name: ui-frontend image: dagworks/ui-frontend:latest build: - context: ./ - dockerfile: deployment/Dockerfile.frontend-prod + context: frontend + dockerfile: Dockerfile.frontend-prod args: - REACT_APP_AUTH_MODE=local - REACT_APP_USE_POSTHOG=false diff --git a/ui/deployment/docker-compose.yml b/ui/docker-compose.yml similarity index 89% rename from ui/deployment/docker-compose.yml rename to ui/docker-compose.yml index b8ffeff61..9060539d1 100644 --- a/ui/deployment/docker-compose.yml +++ b/ui/docker-compose.yml @@ -16,10 +16,11 @@ services: retries: 5 backend: + container_name: ui-backend image: dagworks/ui-backend:latest build: - context: ./ - dockerfile: deployment/Dockerfile.backend + context: backend + dockerfile: Dockerfile.backend entrypoint: ["/bin/bash", "-c", "cd /code/server && ls && ./entrypoint.sh"] volumes: - ./backend:/code @@ -42,10 +43,11 @@ services: - db frontend: + container_name: ui-frontend image: dagworks/ui-frontend:latest build: - context: ./ - dockerfile: deployment/Dockerfile.frontend + context: frontend + dockerfile: Dockerfile.frontend args: - REACT_APP_AUTH_MODE=local - REACT_APP_USE_POSTHOG=false diff --git a/ui/deployment/Dockerfile.frontend b/ui/frontend/Dockerfile.frontend similarity index 88% rename from ui/deployment/Dockerfile.frontend rename to ui/frontend/Dockerfile.frontend index a911ffee0..0b78f7745 100644 --- a/ui/deployment/Dockerfile.frontend +++ b/ui/frontend/Dockerfile.frontend @@ -8,13 +8,13 @@ ARG REACT_APP_AUTH_MODE ARG REACT_APP_USE_POSTHOG # Install app dependencies by copying package.json and package-lock.json -COPY frontend/package.json frontend/package-lock.json ./ +COPY package.json package-lock.json ./ # Install dependencies RUN npm install # Copy the rest of the frontend directory -COPY frontend/ ./ +COPY ./ ./ # Environment variables ENV REACT_APP_AUTH_MODE=${REACT_APP_AUTH_MODE} diff --git a/ui/deployment/Dockerfile.frontend-prod b/ui/frontend/Dockerfile.frontend-prod similarity index 89% rename from ui/deployment/Dockerfile.frontend-prod rename to ui/frontend/Dockerfile.frontend-prod index 670ad0459..e0d705d9a 100644 --- a/ui/deployment/Dockerfile.frontend-prod +++ b/ui/frontend/Dockerfile.frontend-prod @@ -9,13 +9,13 @@ ARG REACT_APP_USE_POSTHOG ARG REACT_APP_API_URL # Install app dependencies by copying package.json and package-lock.json -COPY frontend/package.json frontend/package-lock.json ./ +COPY package.json package-lock.json ./ # Install dependencies RUN npm install # Copy the rest of the frontend directory -COPY frontend . +COPY . . # Environment variables ENV REACT_APP_AUTH_MODE=${REACT_APP_AUTH_MODE} @@ -34,7 +34,7 @@ COPY --from=build-stage /usr/src/app/build /usr/share/nginx/html EXPOSE 8242 # Use the default nginx.conf provided by tiangolo/nginx-rtmp -COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf +COPY ./nginx/nginx.conf /etc/nginx/nginx.conf CMD ["echo", "Frontend running on port 8242, go to http://localhost:8242 to view the app."] diff --git a/ui/frontend/README.md b/ui/frontend/README.md index 47a4ff95c..87b886788 100644 --- a/ui/frontend/README.md +++ b/ui/frontend/README.md @@ -10,3 +10,52 @@ To generate the code for the typescript backend client, run : `npx @rtk-query/codegen-openapi openapi-config.json` from the `frontend` directory, while the backend is running on localhost:8000. + + +## Building docker +## Dev mode +For development you'll want to run + +```bash +./dev.sh --build # to build it all +./dev.sh # to pull docker images but use local code +``` +## You need 9GB assigned to Docker or more to build the frontend +The frontend build requires around 8GB of memory to be assigned to docker to build. +If you run into this, bump your docker memory allocation up to 9GB or more. + + +## Prod mode +For production build you'll want to run + +```bash +./prod.sh # to pull from docker and run +./prod.sh --build # to rebuild images for prod +``` +### Caveats: +You'll want to clean the `backend/dist/` directory to not add unnecessary files to the docker image. + + +## Pushing +How to push to docker hub: +```bash +# retag if needed +docker tag local-image:tagname dagworks/ui-backend:VERSION +# push built image +docker push dagworks/ui-backend:VERSION +# retag as latest +docker tag dagworks/ui-backend:VERSION dagworks/ui-backend:latest +# push latest +docker push dagworks/ui-backend:latest +``` + +```bash +# retag if needed +docker tag local-image:tagname dagworks/ui-frontend:VERSION +# push built image +docker push dagworks/ui-frontend:VERSION +# retag as latest +docker tag dagworks/ui-backend:VERSION dagworks/ui-backend:latest +# push latest +docker push dagworks/ui-backend:latest +``` diff --git a/ui/deployment/nginx/nginx.conf b/ui/frontend/nginx/nginx.conf similarity index 100% rename from ui/deployment/nginx/nginx.conf rename to ui/frontend/nginx/nginx.conf diff --git a/ui/run.sh b/ui/run.sh new file mode 100755 index 000000000..0c351fedd --- /dev/null +++ b/ui/run.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Check if --build parameter is passed +if [[ $1 == "--build" ]]; then + # Run docker-compose up with project directory, verbose mode and build + docker-compose --verbose -f docker-compose-prod.yml up --build +else + # Run docker-compose up with project directory and verbose mode + docker-compose --verbose -f docker-compose-prod.yml up +fi diff --git a/ui/stop.sh b/ui/stop.sh new file mode 100755 index 000000000..33a9f774a --- /dev/null +++ b/ui/stop.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Run docker-compose up with project directory and verbose mode +docker-compose --verbose -f docker-compose.yml down