-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from learntocloud/docker-image
Added Docker support for LTC website
- Loading branch information
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Stage 1: Base image. | ||
FROM node:lts as base | ||
## Disable colour output from yarn to make logs easier to read. | ||
ENV FORCE_COLOR=0 | ||
## Enable corepack. | ||
RUN corepack enable | ||
## Set the working directory to `/opt/docusaurus`. | ||
WORKDIR /opt/docusaurus | ||
|
||
# Stage 2a: Development mode. | ||
FROM base as dev | ||
## Set the working directory to `/opt/docusaurus`. | ||
WORKDIR /opt/docusaurus | ||
## Expose the port that Docusaurus will run on. | ||
EXPOSE 3000 | ||
## Run the development server. | ||
CMD [ -d "node_modules" ] && npm run start --host 0.0.0.0 --poll 1000 || npm run install && npm run start --host 0.0.0.0 --poll 1000 | ||
|
||
# Stage 2b: Production build mode. | ||
FROM base as prod | ||
## Set the working directory to `/opt/docusaurus`. | ||
WORKDIR /opt/docusaurus | ||
## Copy over the source code. | ||
COPY . /opt/docusaurus/ | ||
## Install dependencies with `--immutable` to ensure reproducibility. | ||
RUN npm ci | ||
## Build the static site. | ||
RUN npm run build | ||
|
||
# Stage 3a: Serve with `docusaurus serve`. | ||
FROM prod as serve | ||
## Expose the port that Docusaurus will run on. | ||
EXPOSE 3000 | ||
## Run the production server. | ||
CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--no-open"] | ||
|
||
# Stage 3b: Serve with Caddy. | ||
FROM caddy:2-alpine as caddy | ||
## Copy the Caddyfile. | ||
COPY --from=prod /opt/docusaurus/Caddyfile /etc/caddy/Caddyfile | ||
## Copy the Docusaurus build output. | ||
COPY --from=prod /opt/docusaurus/build /var/docusaurus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters