Skip to content

Commit

Permalink
fix(studio): fix Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher committed Jan 8, 2025
1 parent b696d79 commit f6bce14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-waves-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@asyncapi/studio": patch
---

Fix Docker build for AsyncAPI Studio
24 changes: 12 additions & 12 deletions apps/studio/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Use a UUID as placeholder value to have a unique string to replace.
# Use a UUID as placeholder value to have a unique string to replace.
ARG BASE_URL_PLACEHOLDER=189b303e-37a0-4f6f-8c0a-50333bc3c36e


Expand All @@ -9,10 +9,10 @@ RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN npm install --global turbo
RUN npm install --global turbo@1
COPY . .
RUN turbo prune --scope=@asyncapi/studio --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer

Expand All @@ -21,32 +21,32 @@ ARG BASE_URL_PLACEHOLDER
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app

RUN npm install --global pnpm@latest-10

# First install the dependencies (as they change less often)

COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
RUN PUPPETEER_SKIP_DOWNLOAD=true npm ci

RUN PUPPETEER_SKIP_DOWNLOAD=true pnpm install

# Build the project
COPY --from=builder /app/out/full/ .
RUN PUBLIC_URL=${BASE_URL_PLACEHOLDER} npm run build:studio
RUN PUBLIC_URL=${BASE_URL_PLACEHOLDER} pnpm run build:studio


FROM docker.io/library/nginx:1.25.5-alpine as runtime

ARG BASE_URL_PLACEHOLDER
# The base Nginx image automatically executes all shell scripts
# The base Nginx image automatically executes all shell scripts
# within the /docker-entrypoint.d/ directory ("entrypoint scripts")
# when the container is started. See the relevant logic at
# https://github.com/nginxinc/docker-nginx/blob/master/entrypoint/docker-entrypoint.sh#L16.
ARG ENTRYPOINT_SCRIPT=/docker-entrypoint.d/set-public-url.sh

COPY --from=installer /app/apps/studio/build /usr/share/nginx/html/
# Add an entrypoint script that replaces all occurrences of the
# Add an entrypoint script that replaces all occurrences of the
# placeholder value by the configured base URL. If no base URL
# is configured we assume the application is running at '/'.
RUN echo "find /usr/share/nginx/html/ -type f -print0 | xargs -0 sed -i \"s|${BASE_URL_PLACEHOLDER}|\${BASE_URL}|g\"" > $ENTRYPOINT_SCRIPT && chmod +x $ENTRYPOINT_SCRIPT

FROM runtime
FROM runtime
3 changes: 2 additions & 1 deletion apps/studio/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"./src/*",
"./public/*"
]
}
},
"types": ["cypress"]
},
"include": [
"next-env.d.ts",
Expand Down

0 comments on commit f6bce14

Please sign in to comment.