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

Build prod docker image #450

Merged
merged 14 commits into from
Jan 2, 2025
29 changes: 25 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
# Keep this in sync with the Node version specified for the Conda dev environment (in environment_dev.yml)
FROM node:22-alpine
FROM node:22-slim AS build

RUN corepack enable

WORKDIR /usr/src/app

COPY . .
COPY . ./

# Use the --immutable flag as a precaution. This guarantees that the Docker
# build will fail if `yarn install` results in a different yarn.lock file than
# the one checked into the repo. This could happen for example if the version of
# Yarn used in one dev environment differs from the version used here.
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn \
yarn install --immutable --network-timeout 600000 && \
if [[ ! -f ".env" ]]; then mv .env.example .env; fi;
yarn install --immutable && \
yarn run build && \
STANDALONE=1 yarn run webpack:prod bundle

# ---------------------------------------------------------------------------------
# for production
FROM node:22-slim AS prod

WORKDIR /usr/src/conda-store-ui

COPY --from=build /usr/src/app/server /usr/src/conda-store-ui/server
COPY --from=build /usr/src/app/dist /usr/src/conda-store-ui/dist

RUN cd server && npm install

ENV NODE_ENV=production

EXPOSE 8000

CMD ["node", "server/serve.js"]

# ---------------------------------------------------------------------------------
# for dev
FROM build AS dev

EXPOSE 8000

Expand Down
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ services:
REDIS_PASSWORD: password

conda-store-ui:
build: .
build:
context: .
target: dev
command: "yarn run start:ui"
profiles:
- local-dev
Expand All @@ -93,9 +95,10 @@ services:
volumes:
- ./src:/usr/src/app/src
- ./style:/usr/src/app/style
- ./.env:/usr/src/app/.env
healthcheck:
test:
["CMD", "curl", "--fail", "http://localhost:8000"]
interval: 20s
timeout: 10s
retries: 8
retries: 8
35 changes: 35 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# conda store ui - server

This module provides a node server for running the conda store ui
in production as a standalone application. It provides 3 endpoints:

### /runtime-config.js

This endpoint will return a `text/javascript` file with runtime config
that has been provided as environment variables. For example, given
starting up the server with the environment variables

```
REACT_APP_API_URL=my.condastore.api.com REACT_APP_AUTH_METHOD=cookie node serve.js
```

It will produce the output

```
var condaStoreConfig = {
REACT_APP_API_URL: "my.condastore.api.com",
REACT_APP_AUTH_METHOD: "cookie",
}
```

### /status

This is a simple endpoint that returns a 200 OK if the server is running.

### /*

This route will catch all traffic (that is not caught by the other 2 routes)
and serve the conda store ui application. This is a single page JavaScript
application with its own router that runs in the browser. This frontend router
handles any further routing needed by the UI application, including rendering
a 404 not found page if the route doesn't match any known routes.
Loading
Loading