Skip to content

Commit

Permalink
Use single nginx container for app and docusaurus
Browse files Browse the repository at this point in the history
  • Loading branch information
menghif committed Apr 3, 2022
1 parent 61665ae commit 3db970d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 49 deletions.
4 changes: 4 additions & 0 deletions config/nginx.conf.development.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 48 additions & 7 deletions src/web/app/Dockerfile → src/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
39 changes: 0 additions & 39 deletions src/web/docusaurus/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion src/web/docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/web/docusaurus/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function HomepageHeader() {
<h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<div className={styles.buttons}>
<Link className="button button--secondary button--lg" to="/docs/overview">
<Link className="button button--secondary button--lg" to="./docs/overview">
Docusaurus Tutorial - 5min ⏱️
</Link>
</div>
Expand Down

0 comments on commit 3db970d

Please sign in to comment.