Skip to content

Commit e9029c7

Browse files
committed
[TASK] [WIP] Add docker implementation
Some issues remain with render-guides, made a PR for that: phpDocumentor/guides#817
1 parent 0f570da commit e9029c7

File tree

6 files changed

+3635
-529
lines changed

6 files changed

+3635
-529
lines changed

.dockerignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/.next
12+
**/.cache
13+
**/*.*proj.user
14+
**/*.dbmdl
15+
**/*.jfm
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
**/build
25+
**/dist
26+
**/Input
27+
**/Output
28+
**/Documentation
29+
**/Documentation-GENERATED-temp

Dockerfile

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# syntax=docker/dockerfile:1
2+
ARG NODE_VERSION=20
3+
ARG NODE_PORT=5173
4+
ARG MAIN_WORKDIR=/project
5+
6+
FROM composer:2 as Builder
7+
8+
WORKDIR /opt/guides
9+
COPY composer.* /opt/guides
10+
11+
RUN composer install --no-interaction --no-progress \
12+
--optimize-autoloader --classmap-authoritative
13+
14+
15+
FROM node:${NODE_VERSION}-alpine
16+
17+
# Use production node environment by default.
18+
ENV NODE_ENV production
19+
20+
RUN apk add php82-cli php82-phar php82-dom php82-fileinfo --no-cache
21+
22+
WORKDIR ${MAIN_WORKDIR}
23+
24+
COPY --from=Builder /opt/guides /opt/guides
25+
26+
# Download dependencies as a separate step to take advantage of Docker's caching.
27+
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
28+
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
29+
# into this layer.
30+
RUN --mount=type=bind,source=package.json,target=package.json \
31+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
32+
--mount=type=cache,target=/root/.npm \
33+
npm ci --omit=dev
34+
35+
# Run the application as a non-root user.
36+
# USER node
37+
38+
# Copy the rest of the source files into the image.
39+
COPY . .
40+
41+
# Expose the port that the application listens on.
42+
EXPOSE ${NODE_PORT}
43+
44+
# Run the application.
45+
CMD npm run dev

Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.PHONY: docker-build
2+
docker-build: ## Build docker image 'typo3-documentation-browsersync:local' for local debugging
3+
docker build -t typo3-documentation-browsersync:local .
4+
#docker composer up --build
5+
6+
.PHONY: docker-enter
7+
docker-enter: ## Enter a locally build image
8+
docker run -it --entrypoint=sh --rm \
9+
-v "./Input:/project/Documentation" \
10+
-v "./Output:/project/Documentation-GENERATED-temp" \
11+
typo3-documentation-browsersync:local
12+
13+
.PHONY: render-docs
14+
render-docs: ## Render Documentation using typo3-documentation/render-guides
15+
docker run --rm --pull always \
16+
-v "./Input:/project/Documentation" \
17+
-v "./Output:/project/Documentation-GENERATED-temp" \
18+
ghcr.io/typo3-documentation/render-guides:latest --no-progress Documentation
19+
20+
# Within the container:
21+
# docker run --rm --pull always -v "./Documentation:/project/Documentation" -v "./Documentation-GENERATED-temp:/project/Documentation-GENERATED-temp" ghcr.io/typo3-documentation/render-guides:latest --no-progress Documentation

compose.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
server:
3+
build:
4+
context: .
5+
environment:
6+
NODE_ENV: production
7+
ports:
8+
- "${HOST_PORT:-5173}:${CONTAINER_PORT:-5173}"
9+
environment:
10+
- HOST_PORT
11+
- CONTAINER_PORT

composer.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33
"description": "Standalone project (NodeJS, browsersync) to render and hot-reload changes in ReST documentation to your browser window",
44
"license": "MIT",
55
"require": {
6-
"php": "^8.1"
6+
"php": "^8.2",
7+
"t3docs/render-guides": "dev-main"
78
},
9+
"repositories": [
10+
{
11+
"type": "vcs",
12+
"url": "https://github.com/TYPO3-Documentation/render-guides"
13+
},
14+
{
15+
"type": "vcs",
16+
"url": "https://github.com/brotkrueml/twig-codehighlight"
17+
}
18+
],
819
"require-dev": {
920
"phpstan/phpstan": "^1.10",
1021
"symfony/console": "^6.4",

0 commit comments

Comments
 (0)