Skip to content

Commit bde4b9c

Browse files
authored
Merge pull request #1085 from joshunrau/playground-docker
replace Caddy with http-server
2 parents ac4be54 + db26b10 commit bde4b9c

6 files changed

Lines changed: 35 additions & 41 deletions

File tree

apps/api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN corepack enable
99
RUN pnpm install -g turbo@latest
1010

1111
# PRUNE WORKSPACE
12-
# Note: Here we cannot use --docker, as is recomended, since the generated
12+
# Note: Here we cannot use --docker, as is recommended, since the generated
1313
# json directory does not allow linking package.json executable files
1414
FROM base AS pruner
1515
COPY . .

apps/gateway/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN corepack enable
99
RUN pnpm install -g turbo@latest
1010

1111
# PRUNE WORKSPACE
12-
# Note: Here we cannot use --docker, as is recomended, since the generated
12+
# Note: Here we cannot use --docker, as is recommended, since the generated
1313
# json directory does not allow linking package.json executable files
1414
FROM base AS pruner
1515
COPY . .

apps/playground/Dockerfile

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
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", "." ]

apps/playground/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"private": true,
66
"license": "Apache-2.0",
77
"scripts": {
8-
"build": "tsc && env-cmd -f ../../.env pnpm exec vite build",
8+
"build": "tsc && pnpm exec vite build",
99
"deploy": "rsync -r dist/* unrjos@cloud1.douglasneuroinformatics.ca:/home/unrjos/www/playground.opendatacapture.org",
10-
"dev": "NODE_ENV=development env-cmd -f ../../.env pnpm exec vite",
10+
"dev": "NODE_ENV=development pnpm exec vite",
1111
"format": "prettier --write src",
1212
"lint": "tsc && eslint --fix src",
13-
"storybook": "env-cmd -f ../../.env storybook dev -p 6006"
13+
"storybook": "storybook dev -p 6006"
1414
},
1515
"dependencies": {
1616
"@douglasneuroinformatics/libcrypto": "catalog:",

apps/web/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN corepack enable
88
RUN pnpm install -g turbo@latest
99

1010
# PRUNE WORKSPACE
11-
# Note: Here we cannot use --docker, as is recomended, since the generated
11+
# Note: Here we cannot use --docker, as is recommended, since the generated
1212
# json directory does not allow linking package.json executable files
1313
FROM base AS builder
1414
COPY . .

docker-compose.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,14 @@ services:
111111
- '' #load by default without having to specify docker compose --profile
112112
- fullstack
113113
playground:
114-
image: caddy:2.7-alpine
115114
build:
116115
context: .
117116
dockerfile: ./apps/playground/Dockerfile
118117
environment:
119118
- NODE_ENV=production
120-
- PLAYGROUND_URL=http://localhost:3000
121119
ports:
122-
- "3000:3000"
120+
- '3750:80'
123121
restart: unless-stopped
124122
profiles:
125123
- fullstack
124+
- playground

0 commit comments

Comments
 (0)