Skip to content

Commit

Permalink
Added Ubuntu Dockerfile and new unit test script
Browse files Browse the repository at this point in the history
  • Loading branch information
thenets committed Mar 2, 2020
1 parent 423cd26 commit e594f0f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
chmod +x run-unit-tests.sh
./run-unit-tests.sh $(NAME):$(TAG)
24 changes: 24 additions & 0 deletions run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -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}"

40 changes: 40 additions & 0 deletions ubuntu.dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit e594f0f

Please sign in to comment.