1- # The following Dockerfile uses a two stage build which first builds the playground and then copies it into the another caddy image to serve it
2-
3- # use the apline contianer to build odc
4- FROM alpine:3.19 AS builder
5-
6- # install nodejs and required dependencies
7- # RUN apk add --no-cache curl git build-base python3 nodejs-current npm bash openssl
8- RUN apk add --no-cache nodejs-current npm bash openssl
9- RUN npm install -g pnpm
10-
11- # set the working dir and copy the current odc instance into the new container
12- WORKDIR /src
13- COPY . /src
14-
15- # install dependencies, generate the environment, and build the playground
16- RUN pnpm install
17- RUN ./scripts/generate-env.sh
18- RUN pnpm build --filter=@opendatacapture/playground
19-
20- # use the caddy image to serve the playground
21- FROM caddy:2.7-alpine
22-
23- # overwrite the default caddy files with odc's
24- RUN rm -rf /usr/share/caddy/*
25- COPY --from=builder /src/apps/playground/dist /usr/share/caddy
26-
27- # make caddy listen on port 3000 and serve odc
28- RUN echo -e ":3000 {\n root * /usr/share/caddy\n file_server\n }\n " > /etc/caddy/Caddyfile
29- EXPOSE 3000
30-
31- # serve odc
32- CMD ["caddy" , "run" , "--config" , "/etc/caddy/Caddyfile" ]
1+ FROM node:iron AS base
2+ WORKDIR /app
3+ ENV PNPM_HOME="/pnpm"
4+ ENV PATH="$PNPM_HOME:$PATH"
5+ ENV NODE_OPTIONS="--max-old-space-size=8192"
6+ RUN corepack enable
7+ RUN pnpm install -g turbo@latest
8+
9+ # PRUNE WORKSPACE
10+ # Note: Here we cannot use --docker, as is recommended, since the generated
11+ # json directory does not allow linking package.json executable files
12+ FROM base AS pruner
13+ COPY . .
14+ RUN turbo prune @opendatacapture/playground
15+
16+ # INSTALL DEPENDENCIES AND BUILD
17+ FROM base AS builder
18+ COPY tsconfig.base.json vitest.config.ts vitest.workspace.ts ./
19+ COPY --from=pruner /app/out/ .
20+ RUN pnpm install --frozen-lockfile
21+ RUN turbo build --filter=@opendatacapture/playground
22+
23+ # SERVE PLAYGROUND
24+ FROM base AS runner
25+ RUN pnpm install -g http-server@14.1.1
26+ COPY --from=builder /app/apps/playground/dist ./
27+ CMD [ "http-server" , "-s" , "-p" , "80" , "-P" , "http://localhost:80?" , "--gzip" , "." ]
0 commit comments