diff --git a/.env.template b/.env.template new file mode 100644 index 0000000000000000000000000000000000000000..c4b0b2598328c2b78bf1688083a5345386608f15 --- /dev/null +++ b/.env.template @@ -0,0 +1,4 @@ +# host port +PORT= +# container restart policy +RESTART= diff --git a/.gitignore b/.gitignore index 123b79e6fe04f9d35c119def3b0875d2c0469396..512d934a3627d622119f5beb1d27a854507c3aea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.env node_modules/ dist/ package-lock.json diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000000000000000000000000000000000000..f3c6a8f2e20d422abbfd9903b36539e1c4b350a5 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,4 @@ +:80 { + root * /srv + file_server browse +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d89317f1d520f899d10483b1d0aac8c46ba2bad2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:latest as builder +RUN apk add npm git + +COPY . /opt +WORKDIR /opt +RUN npm install +RUN npm run build + +FROM caddy:latest as httpd +COPY --from=builder /opt/public /srv diff --git a/README.md b/README.md index 4baf1cfa3c3d800974eea87e3f67f0ef82d9b6c5..d78d52eddba2ef91042c98e7eae0578930c32341 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,3 @@ -## Integrating Mirador +## Mirador Video Annotation POC -This repository is designed to show integrating Mirador 3 with modern frontend build systems. - -### Dependencies - -You will likely need to have at least the following dependencies available in your `package.json`. - - - `mirador` - - `react` - - `react-dom` - - `mirador-image-tools` - A plugin just to test plugin integration - -### Webpack - -See `./webpack` for a basic webpack setup for Mirador 3 + a plugin. - -```sh -npm run webpack -``` - -### Parcel - -See `./parcel`, but essentially it is just an html file referencing the JavaScript. - -```sh -npm run parcel -``` +Run `docker-compose up -d`, which will serve a mirador instance to `http://localhost:8080`. If sources files are modified, run `docker-compose up -d --build` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..019b574ad1ef8770bf8a680f397c372fa722891c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.9" +services: + httpd: + build: . + restart: $RESTART + ports: + - $PORT:80 + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile diff --git a/package.json b/package.json index dc164001f2e90cb76f88ba1f533116c0e3bd304b..c247ee3f4313baa2464e4e3140ee5694f4a732d9 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "", "private": true, "scripts": { - "webpack": "webpack --config webpack/webpack.config.js", - "test": "echo \"Error: no test specified\" && exit 1" + "build": "webpack --config webpack.config.js", + "serve": "webpack serve --config webpack.config.js" }, "author": "", "license": "ISC", @@ -14,7 +14,9 @@ "mirador": "git+https://gitlab.tetras-libre.fr/iiif/mirador-video-annotation#wip-webpack-from-git", "react": "^16.13.1", "react-dom": "^16.13.1", - "style-loader": "^1.2.1", + "style-loader": "^1.2.1" + }, + "devDependencies": { "webpack": "^4.43.0", "webpack-cli": "^4.3.12" } diff --git a/webpack/index.html b/public/index.html similarity index 58% rename from webpack/index.html rename to public/index.html index 3b8756031929f696c9b02c089afae1e096b8b58e..e7842b1fdae6cbf055d4eb965853a4bb510e52ab 100644 --- a/webpack/index.html +++ b/public/index.html @@ -2,10 +2,10 @@ <html> <head> <meta charset="utf-8" /> - <title>Basic Mirador</title> + <title>Mirador Video Annotations</title> </head> <body> <div id="demo"></div> - <script src="dist/main.js"></script> + <script src="/dist/main.js"></script> </body> </html> diff --git a/webpack/webpack.config.js b/webpack.config.js similarity index 72% rename from webpack/webpack.config.js rename to webpack.config.js index 25c398e9a023487e303e94a8654858f97ae74671..d487af5301c2a2d03037db99295c2bcbee3bb9a4 100644 --- a/webpack/webpack.config.js +++ b/webpack.config.js @@ -4,7 +4,7 @@ module.exports = { entry: './src/index.js', output: { filename: 'main.js', - path: path.resolve(__dirname, 'dist'), + path: path.resolve(__dirname, 'public/dist'), publicPath: './dist/', - }, + } };