Skip to content

Commit

Permalink
write down instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
longshuicy committed Aug 19, 2024
1 parent 9875368 commit bb30886
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@
)
api_router.include_router(status.router, prefix="/status", tags=["status"])
api_router.include_router(keycloak.router, prefix="/auth", tags=["auth"])

if not settings.API_V2_STR.startswith("/"):
settings.API_V2_STR = "/" + settings.API_V2_STR
app.include_router(api_router, prefix=settings.API_V2_STR)


Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ services:
frontend_url: http://localhost
# For deploy to subdirectory
BASE_URL_ROUTE: ${BASE_URL_ROUTE:-}
API_V2_STR: "/${BASE_URL_ROUTE}/api/v2"
API_V2_STR: "${BASE_URL_ROUTE}/api/v2"
depends_on:
- mongo
- minio-nginx
Expand Down
57 changes: 57 additions & 0 deletions docs/docs/admins/deployatsubdirectory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Deploying Application to Subdirectory "clowder"

This guide will walk you through the steps to deploy your frontend and backend applications to the
subdirectory `/clowder`, ensuring that both the frontend and backend are accessible under this path.

## Step 1: Build the Frontend Image

To deploy the frontend application under `/clowder`, build the Docker image with the appropriate build arguments:

```bash
docker build --no-cache -t clowder/clowder2-frontend:basename \
--build-arg BASE_URL_ROUTE=clowder \
--build-arg CLOWDER_REMOTE_HOSTNAME="http://localhost/clowder" \
.
```

- **`BASE_URL_ROUTE=clowder`**: Configures the frontend to operate under the `/clowder` subdirectory.
- **`CLOWDER_REMOTE_HOSTNAME=clowder`**: Point to the backend service that frontend will request, which should match
the subdirectory "/clowder" as well.

## Step 2: Modify `docker-compose.yml` to Use the Built Image

In your `docker-compose.yml`, update the frontend service to use the newly built image:

```yaml
frontend:
image: "clowder/clowder2-frontend:basename"
```
This ensures that the correct image, configured for the `/clowder` subdirectory, is used when deploying.

## Step 3: Set the `BASE_URL_ROUTE` Environment Variable

Before running Docker Compose, make sure the `BASE_URL_ROUTE` environment variable is set to `clowder`. This ensures
that both the frontend and backend services are configured to operate under the `/clowder` subdirectory.

```bash
export BASE_URL_ROUTE=clowder
echo $BASE_URL_ROUTE
```

- This environment variable ensures that the backend is also aware that it needs to operate under the `/clowder`
subdirectory.

## Step 4: Start the Services with Docker Compose

Now, start your services using Docker Compose:

```bash
docker-compose up
```

- **Backend**: The backend service will be accessible at `http://localhost/clowder/api/v2`.
- **Frontend**: The frontend service will be accessible at `http://localhost/clowder`.

By following these steps, both your backend and frontend services will be correctly deployed under the `/clowder`
subdirectory, making them accessible through the configured paths.

0 comments on commit bb30886

Please sign in to comment.