Skip to content

Commit

Permalink
Merge pull request #207 from ocaml-opam/revert-205-updates
Browse files Browse the repository at this point in the history
Revert "Update for opam.ocaml.org"
  • Loading branch information
kit-ty-kate authored Apr 20, 2022
2 parents 02e2d04 + 6019443 commit bf20494
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 48 deletions.
9 changes: 9 additions & 0 deletions .merlin
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PKG cmdliner
PKG cow
PKG opam-lib
PKG opamfu

B src/_build
B src/_build/apalog
S src
S src/apalog
33 changes: 10 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# syntax=docker/dockerfile:1.3
FROM ocaml/opam:alpine-3.14-ocaml-4.13 as build-opam2web
RUN sudo apk add g++ gmp-dev
RUN git clone https://github.com/ocaml/opam2web.git --depth 1 /home/opam/opam2web
# syntax=docker/dockerfile:1
FROM ocaml/opam:alpine-3.14-ocaml-4.10 as build-opam2web
RUN sudo apk add g++
RUN git clone https://github.com/ocaml/opam2web --depth 1 /home/opam/opam2web
WORKDIR /home/opam/opam2web
ENV OCAMLRUNPARAM b
RUN sudo mkdir -p /opt/opam2web && sudo chown opam:opam /opt/opam2web
RUN opam repo set-url default git+https://github.com/ocaml/opam-repository.git#${OPAM_GIT_SHA}
RUN sudo mv /usr/bin/opam-2.1 /usr/bin/opam
RUN opam repo set-url default https://opam-dev.ocaml.org/
RUN opam install . --destdir /opt/opam2web
RUN cp -r content /opt/opam2web/share/opam2web/
RUN rm -rf /opt/opam2web/share/opam2web/lib
Expand All @@ -16,8 +17,7 @@ RUN git clone https://github.com/ocaml/opam.wiki.git --depth 1 -b old_wiki /opt/
RUN git clone https://github.com/ocaml/opam --depth 1 -b 1.2 /tmp/opam-1.2 \
&& mv /tmp/opam-1.2/doc/pages /opt/opam2web/share/opam2web/content/doc/1.2 \
&& rm -rf /tmp/opam-1.2

FROM ocaml/opam:alpine-3.14-ocaml-4.13 as build-opam-doc
FROM ocaml/opam:alpine-3.14-ocaml-4.10 as build-opam-doc
RUN sudo apk add cgit groff
RUN sudo mkdir -p /usr/local/bin \
&& echo -e '#!/bin/sh -e\n\
Expand All @@ -40,24 +40,11 @@ RUN sudo mkdir -p /opt/opam/doc && sudo chown -R opam:opam /opt/opam
RUN cp -r doc/html /opt/opam/doc/api
RUN cp -r doc/man-html /opt/opam/doc/man
RUN cp -r doc/pages/* /opt/opam/doc/

FROM --platform=linux/amd64 ocaml/opam:archive as opam-archive
FROM ocaml/opam.ocaml.org-legacy as opam-legacy
FROM alpine:3.14 as opam2web
RUN apk add --update git curl rsync libstdc++ rdfind
COPY --from=opam-legacy . /www
RUN apk add git curl rsync libstdc++
COPY --from=build-opam2web /opt/opam2web /usr/local
COPY --from=build-opam-doc /usr/bin/opam /usr/local/bin/opam
COPY --from=build-opam-doc /opt/opam/doc /usr/local/share/opam2web/content/doc
RUN --mount=type=bind,target=/cache,from=opam-archive rsync -aH /cache/cache/ /www/cache/
COPY ext/key/opam-dev-team.pgp /www/opam-dev-pubkey.pgp
ADD bin/opam-web.sh /usr/local/bin
ARG DOMAIN=opam.ocaml.org
ARG OPAM_GIT_SHA
RUN echo ${OPAM_GIT_SHA} >> /www/opam_git_sha
RUN /usr/local/bin/opam-web.sh ${DOMAIN} ${OPAM_GIT_SHA}

FROM caddy:alpine
WORKDIR /srv
COPY --from=opam2web /www /usr/share/caddy
ENTRYPOINT ["caddy", "file-server"]
VOLUME ["/persist"]
VOLUME ["/www"]
7 changes: 7 additions & 0 deletions Dockerfile.image
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# syntax = docker/dockerfile:1.0.2-experimental
FROM opam-website-data
FROM ocaml/opam.ocaml.org-legacy
FROM caddy:alpine
WORKDIR /srv
COPY --from=0 . /srv
COPY --from=1 . /srv
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ opam2web
A tool to generate a website from an OPAM universe

This utility creates a static website from an OPAM universe, listing all
available packages and their details. A homepage and OPAM documentation is
available packages and their details. A homepage and OPAM documentation is
included as well.

The latest release of opam2web is available via
Expand Down
56 changes: 39 additions & 17 deletions bin/opam-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,38 @@

set -uex

if [[ $# -eq 3 ]] ; then
echo 'Usage: $0 BASEURL OPAM_GIT_SHA'
exit 2
fi
BASEURL=$1 && shift && [ $# -eq 0 ] || { echo "Usage: $0 BASEURL" && exit 2; }

BASEURL=$1
OPAM_GIT_SHA=$2
# /persist may contain:
# /opam-repository (bare git clone)
# /platform-blog (bare git clone)
# /legacy (subdirectories copied verbatim)
# /repo-cache (as generated by 'opam admin', 'cache/' and 'archives/' subdirs)
# /logs-cache (cache of parsed logs used by opam2web)

cd /www
# Checkout a specific commit as supplied by ocurrent-deployer pipeline.
git clone https://github.com/ocaml/opam-repository.git --single-branch --branch master opam-repository &&
cd opam-repository &&
git checkout ${OPAM_GIT_SHA} &&
cd ..
cd /persist
# clone/update opam repo
if [ -d opam-repository ]; then
git -C opam-repository fetch https://github.com/ocaml/opam-repository +master:master
else
git clone https://github.com/ocaml/opam-repository opam-repository --bare --single-branch --branch master
fi

mv opam-repository/* .
mv opam-repository/.git .
rm -rf opam-repository
# clone/update opam blog
if [ -d blog ]; then
git -C blog fetch https://github.com/ocaml/platform-blog +master:master
else
git clone https://github.com/ocaml/platform-blog blog --bare --single-branch --branch master
fi

cd /www
# clone/update opam-repo to /www
if [ -d .git ]; then
git fetch /persist/opam-repository
if ! git reset FETCH_HEAD --hard; then git clean -ffdx; git reset FETCH_HEAD --hard; fi
else
git clone -s /persist/opam-repository .
fi
# Overwrite 'repo' file, and dispatch all non-standard versions
cat <<EOF >repo
opam-version: "2.0"
Expand All @@ -32,18 +45,27 @@ redirect: [
"https://${BASEURL}/1.2.2" { opam-version < "2.0~" }
]
EOF
opam admin cache --link=archives ./cache
mkdir -p /persist/repo-cache/archives
mkdir -p /persist/repo-cache/cache
mkdir -p archives
opam admin cache -n --link=archives /persist/repo-cache/cache
rsync -a /persist/repo-cache/cache .
echo 'archive-mirrors: "cache"' >> repo
if [ -d /persist/legacy ]; then rsync -a /persist/legacy .; fi
opam admin index --minimal-urls-txt

cp -r /usr/local/share/opam2web/content /tmp/
git clone https://github.com/ocaml/platform-blog --single-branch --branch master /tmp/content/blog
git clone -s /persist/blog /tmp/content/blog

rm -rf /www/ext
mkdir -p /www/ext
cp -r -L /usr/local/share/opam2web/css /www/ext
cp -r -L /usr/local/share/opam2web/img /www/ext
cp -r -L /usr/local/share/opam2web/js /www/ext

mkdir -p /persist/logs-cache ~/.cache
ln -sf /persist/logs-cache ~/.cache/opam2web2

if [ -r /logs/access.log ]; then
STATS_ARG="--statistics=/logs/access.log"
else
Expand Down
12 changes: 6 additions & 6 deletions bin/opam2web.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ let default_cmd =
~docv:"REPOSITORY"
~doc:"Directories containing the repositories to consider")
in
let info = Cmd.info "opam2web" ~version ~doc ~man in
let term = Term.(const build $ log_files $ out_dir $ content_dir
$ repositories_arg $ root_uri $ blog_source_uri) in
Cmd.v info term

Term.(pure build $ log_files $ out_dir $ content_dir
$ repositories_arg $ root_uri $ blog_source_uri),
Term.info "opam2web" ~version ~doc ~man

let () =
OpamFormatConfig.init ();
OpamStd.Config.init ();
OpamRepositoryConfig.init ();
OpamSolverConfig.init ();
OpamStateConfig.init ();
exit @@ Cmd.eval default_cmd
match Term.eval default_cmd with
| `Error _ -> exit 1
| _ -> exit 0
3 changes: 3 additions & 0 deletions bin/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if [ $1 = "" ]; then
exit 1
fi

tar -C /var/lib/docker/volumes/opam-website/_data/ -cf - . | docker image import - opam-website-data
DOCKER_BUILDKIT=1 docker build -t opam-website-live -f Dockerfile.image .
docker kill opam-website-live || true
docker rm opam-website-live || true
docker run -d -p 80:80 -p 443:443 -v caddy-data:/data --name opam-website-live opam-website-live caddy file-server -domain $1
docker system prune -f
2 changes: 1 addition & 1 deletion src/o2wBlog.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ let make_redirect ~root entries =
| [] -> Html.p (Html.string "No blog pages.")
| first_entry::_ ->
let blog_uri =
Uri.(resolve "http" root (of_string "/blog/"))
Uri.(resolve "http" root (of_string "blog/"))
in
let post_uri =
Uri.(resolve "http" blog_uri (of_string (first_entry.blog_name^"/")))
Expand Down

0 comments on commit bf20494

Please sign in to comment.