diff --git a/Dockerfile b/Dockerfile index 05cd0b458aec2134da597c3080580e47c0cb7cb3..a91a3f8031a8f4cd8785609f49319f199d37e3a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,8 @@ LABEL maintainer="luiz@thenets.org" ENV PARSOID_HOME=/var/lib/parsoid \ PARSOID_USER=parsoid \ - # PARSOID_VERSION [v0.8.1, v0.9.0, v0.10.0, master] - PARSOID_VERSION=master + # PARSOID_VERSION [v0.8.1, v0.9.0, v0.10.0, v0.11.0, master] + PARSOID_VERSION=v0.11.0 COPY run-parsoid.sh /run-parsoid.sh diff --git a/Makefile b/Makefile index c6b4051bf8556ea0a25615e8ea2f85de028dd3d0..6d3538a6850b0934ba7b7c9b7e03125bf3352b16 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ post-build: docker-build: docker build -t $(NAME):$(TAG) --rm . +docker-build-ubuntu: + docker build -f ubuntu.dockerfile -t $(NAME):$(TAG) --rm . + shell: docker run -it --rm --entrypoint=$(SHELL) -p 8080:80 $(NAME):$(TAG) @@ -22,4 +25,5 @@ test: docker run -it --rm -p 8080:8000 -e PARSOID_DOMAIN_localhost=http://localhost/w/api.php $(NAME):$(TAG) unit-test: - docker run -it --rm -w "/var/lib/parsoid" $(NAME):$(TAG) npm test \ No newline at end of file + chmod +x run-unit-tests.sh + ./run-unit-tests.sh $(NAME):$(TAG) \ No newline at end of file diff --git a/run-unit-tests.sh b/run-unit-tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..4f9b3a8657722d5b67bc75ee5e228a9ab431124d --- /dev/null +++ b/run-unit-tests.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo "[ERROR] Missing the image tag as arg!" >/dev/stderr + echo "How to use: ./run-unit-tests.sh thenets/parsoid:0.11" + exit 1 +fi + +set -x +DOCKER_IMAGE=$1 + +TEMP_DIR=$(mktemp -d) + +docker run -it --rm \ + -w "/var/lib/parsoid" \ + -v ${TEMP_DIR}/npm_logs:/root/.npm/_logs/ \ + ${DOCKER_IMAGE} \ + npm test + +set +x + +echo "" +echo "[DONE] Log files at: ${TEMP_DIR}" + diff --git a/ubuntu.dockerfile b/ubuntu.dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..65377900dba444f7c249be668ec46d036a861511 --- /dev/null +++ b/ubuntu.dockerfile @@ -0,0 +1,40 @@ +FROM node:13 + +LABEL maintainer="luiz@thenets.org" + +ENV PARSOID_HOME=/var/lib/parsoid \ + PARSOID_USER=parsoid \ + # PARSOID_VERSION [v0.8.1, v0.9.0, v0.10.0, v0.11.0, master] + PARSOID_VERSION=v0.11.0 + +COPY run-parsoid.sh /run-parsoid.sh + +# Parsoid setup +RUN set -x \ + # Install required packages + && apt-get update \ + && apt-get install -y python git tar bash make + +RUN set -x \ + # Add user + && useradd -M -u 1001 -s /bin/bash ${PARSOID_USER} \ + # Set permissions + && chmod -v +x /run-parsoid.sh \ + # Core + && mkdir -p ${PARSOID_HOME} \ + && git clone \ + --branch ${PARSOID_VERSION} \ + --single-branch \ + --depth 1 \ + --quiet \ + https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid \ + ${PARSOID_HOME} + +RUN set -x \ + && cd ${PARSOID_HOME} \ + && npm install + +EXPOSE 8000 +EXPOSE 8001 + +CMD ["/run-parsoid.sh"]