Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 10 additions & 44 deletions air_gapped/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,14 @@
FROM docker.elastic.co/docs/preview:latest AS build
FROM cgr.dev/chainguard/wolfi-base

COPY air_gapped/work/target_repo.git /docs_build/.repos/target_repo.git

FROM chainguard/wolfi-base:latest
#FROM perl:5.42-bookworm
RUN apk update
RUN apk add perl
RUN apk add curl
RUN apk add perl-app-cpanminus

RUN apk add gcc make git patch perl-dev wget
RUN apk add openssl-dev
RUN apk add zlib-dev
RUN apk add perl-net-ssleay

ENV PERL5LIB=/usr/local/lib/perl5
ENV PATH=/usr/local/bin:$PATH
RUN apk update && apk add nodejs git npm

WORKDIR /
RUN cpanm -n XML::LibXML
RUN cpanm -n File::Copy::Recursive
RUN cpanm -n Path::Class
RUN cpanm -n Parallel::ForkManager
RUN cpanm -n YAML
#RUN apt update -y
#RUN apt-get install -y perl
#RUN apt-get install -y nginx
#RUN apt-get install -y nodejs
#RUN apt-get install -y git

#RUN apt-get install -y libxml-simple-perl
#RUN apt-get install -y libfile-copy-recursive-perl
#RUN apt-get install -y libpath-class-perl
#RUN apt-get install -y libcapture-tiny-perl
#RUN apt-get install -y libparallel-forkmanager-perl
#RUN apt-get install -y libyaml-perl

RUN apk add nginx
RUN apk add nodejs

COPY --from=build /docs_build /docs_build
COPY --from=build /node_modules /node_modules
WORKDIR /app
COPY air_gapped/work/target_repo.git /docs_build/.repos/target_repo.git
COPY --chown=node:node preview /app/preview/
COPY --chown=node:node template /app/template/
COPY --chown=node:node preview/package.json /app/package.json
WORKDIR /app
RUN npm install

RUN adduser -D nginx
RUN mkdir -p /var/lib/nginx/tmp/
ENTRYPOINT ["node", "preview/cli.js", "git", "/docs_build/.repos/target_repo.git"]

CMD ["/docs_build/build_docs.pl", "--in_standard_docker", "--gapped", "--preview"]
2 changes: 2 additions & 0 deletions air_gapped/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*
!air_gapped
!preview
!template
1 change: 1 addition & 0 deletions air_gapped/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mkdir air_gapped/work
git clone --reference ~/.git-references/built-docs.git --dissociate \
--depth 2 --branch master --bare \
[email protected]:elastic/built-docs.git air_gapped/work/target_repo.git

GIT_DIR=air_gapped/work/target_repo.git git fetch

# Build the images
Expand Down
1 change: 1 addition & 0 deletions air_gapped/build_bk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mkdir air_gapped/work
git clone --reference /opt/git-mirrors/built-docs.git --dissociate \
--depth 2 --branch master --bare \
[email protected]:elastic/built-docs.git air_gapped/work/target_repo.git

GIT_DIR=air_gapped/work/target_repo.git git fetch

# Build the images
Expand Down
6 changes: 2 additions & 4 deletions air_gapped/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ set -e
cd $(git rev-parse --show-toplevel)

source ./air_gapped/build.sh
id=$(docker run --rm \
--publish 8000:8000/tcp \
-d \
$AIR_GAPPED)
id=$(docker run --rm --publish 8000:8000/tcp -d $AIR_GAPPED)

echo "Started the air gapped docs. Some useful commands:"
echo " docker kill $id"
echo " docker logs -tf $id"
Expand Down
8 changes: 8 additions & 0 deletions preview/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"license": "SEE LICENSE IN README.asciidoc",
"dependencies": {
"yargs": "^14.0.0",
"dedent": "^0.7.0",
"recursive-copy": "^2.0.10"
}
}
7 changes: 6 additions & 1 deletion preview/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ const checkRedirects = async (core, path) => {

module.exports = Core => {
const server = http.createServer((request, response) => {
const parsedUrl = url.parse(request.url);
let host = process.env.HOST;
if (host == null || host === "") {
host = "localhost";
}

const parsedUrl = new URL(`http://${host}${request.url}`);
const prefix = hostPrefix(request.headers['host']);
const core = Core(prefix);
requestHandler(core, parsedUrl, response)
Expand Down