Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors docker compose file setup #1061

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Original file line number Diff line number Diff line change
Expand Up @@ -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/
19 changes: 0 additions & 19 deletions ui/deployment/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions ui/deployment/dev.sh

This file was deleted.

13 changes: 0 additions & 13 deletions ui/deployment/run.sh

This file was deleted.

7 changes: 0 additions & 7 deletions ui/deployment/stop.sh

This file was deleted.

10 changes: 10 additions & 0 deletions ui/dev.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions ui/deployment/docker-compose.yml → ui/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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."]

Expand Down
49 changes: 49 additions & 0 deletions ui/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
File renamed without changes.
10 changes: 10 additions & 0 deletions ui/run.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions ui/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Run docker-compose up with project directory and verbose mode
docker-compose --verbose -f docker-compose.yml down
Loading