diff --git a/config/nginx.conf.development.template b/config/nginx.conf.development.template index 7738343ac8..aa4c936fc9 100644 --- a/config/nginx.conf.development.template +++ b/config/nginx.conf.development.template @@ -151,6 +151,10 @@ http { proxy_pass http://planet:9876; } + location /docs { + root /usr/share/nginx/html; + } + # Static next.js front-end location / { # Directory from which we serve Next's static content diff --git a/docker/development.yml b/docker/development.yml index cc0f3422aa..5fa3b567f3 100644 --- a/docker/development.yml +++ b/docker/development.yml @@ -13,7 +13,7 @@ services: # API Gateway nginx: build: - context: ../src/web/app + context: ../src/web cache_from: - docker.cdot.systems/nginx:buildcache # next.js needs build-time access to a number of API URL values, forward as ARGs diff --git a/src/web/app/Dockerfile b/src/web/Dockerfile similarity index 54% rename from src/web/app/Dockerfile rename to src/web/Dockerfile index f7d69b34e6..c6849c9e7f 100644 --- a/src/web/app/Dockerfile +++ b/src/web/Dockerfile @@ -15,13 +15,35 @@ ARG WEB_URL ARG SUPABASE_URL ARG ANON_KEY +## Base ########################################################################### FROM node:16 as base -WORKDIR /frontend +RUN npm install -g pnpm -COPY . . +## Dependencies ################################################################### +## Telescope app +FROM base as dependencies-app -FROM base as dependencies +WORKDIR /app + +COPY ./app/package.json ./ + +RUN pnpm install + +## Telescope docs +FROM base as dependencies-docs + +WORKDIR /docs + +COPY ./docusaurus/package.json ./ + +RUN pnpm install + +## Build ###################################################################### +## Telescope app +FROM base as build-app + +WORKDIR /app # Copy the various API URLs build args over so next.js can see them in next.config.js ARG API_URL @@ -57,10 +79,29 @@ ENV NEXT_PUBLIC_SUPABASE_URL ${SUPABASE_URL} ARG ANON_KEY ENV NEXT_PUBLIC_ANON_KEY ${ANON_KEY} -RUN npm install --no-package-lock +COPY ./app ./ + +COPY --from=dependencies-app /app/node_modules ./node_modules + +RUN pnpm build + +## Telescope docs +FROM base as build-docs + +WORKDIR /docs + +COPY ./docusaurus ./ + +COPY --from=dependencies-docs /docs/node_modules ./node_modules + +RUN pnpm build + +## Deploy ###################################################################### +FROM nginx:1.20.2-alpine as deploy + +WORKDIR / -RUN npm run build +COPY --from=build-app /app/out /var/www/data -FROM nginx:stable-alpine as build +COPY --from=build-docs /docs/build /usr/share/nginx/html/docs -COPY --from=dependencies /frontend/out /var/www/data diff --git a/src/web/docusaurus/Dockerfile b/src/web/docusaurus/Dockerfile deleted file mode 100644 index b4f29a74bd..0000000000 --- a/src/web/docusaurus/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -## Base ######################################################################## -# Set up the base layer -FROM node:16 as base - -# Reduce npm log spam and colour during install within Docker -ENV NPM_CONFIG_LOGLEVEL=warn -ENV NPM_CONFIG_COLOR=false - -RUN npm install -g pnpm - -WORKDIR /app - -## Dependencies ################################################################### -# Stage for installing prod dependencies -FROM base as dependencies-dev - -COPY package.json ./ - -RUN pnpm install - -# Builder ######################################################################## -# Stage for building our app -FROM base as builder - -COPY --from=dependencies-dev /app/node_modules ./node_modules - -COPY . . - -RUN pnpm build - -## Deploy ###################################################################### -# Use 1.20.2-alpine nginx image -FROM nginx:1.20.2-alpine as deploy - -COPY --from=builder /app/build /usr/share/nginx/html/ - -# Add Healthcheck -HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ - CMD curl --fail localhost:80 || exit 1 diff --git a/src/web/docusaurus/docusaurus.config.js b/src/web/docusaurus/docusaurus.config.js index ddfbc0a0ee..6243135ba4 100644 --- a/src/web/docusaurus/docusaurus.config.js +++ b/src/web/docusaurus/docusaurus.config.js @@ -9,7 +9,7 @@ const config = { title: 'Telescope', tagline: "A tool for tracking blogs in orbit around Seneca's open source involvement", url: 'https://telescope.cdot.systems', - baseUrl: '/', + baseUrl: '/docs/', onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'throw', favicon: 'img/favicon.ico', diff --git a/src/web/docusaurus/src/pages/index.js b/src/web/docusaurus/src/pages/index.js index 79a2daab88..2e50e90bd0 100644 --- a/src/web/docusaurus/src/pages/index.js +++ b/src/web/docusaurus/src/pages/index.js @@ -14,7 +14,7 @@ function HomepageHeader() {
{siteConfig.tagline}