Skip to content

Commit

Permalink
Add Docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
gcapes committed Oct 6, 2022
1 parent 464e088 commit 4e9fb0d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1.4.2

FROM ubuntu:20.04

## Install requirements

RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC \
apt-get install -y \
nodejs \
npm

## Install ro-crate-html-js
RUN npm install ro-crate-html-js
ENV PATH "/node_modules/.bin:$PATH"

## Create directory for output
RUN mkdir /tmp/output
1 change: 1 addition & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo docker build -t rocrate-preview .
31 changes: 31 additions & 0 deletions docker/create-and-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Create and run a Docker container

## Create a Dockerfile

Create a `Dockerfile` which starts with a base docker image e.g. Ubuntu.

In this file, you install the software you need, set environment variables, create directories etc.

[Example](Dockerfile).

## Build the container

Use the command `docker build -t` to create a container and tag it with a name.

Docker is looking for a file called `Dockerfile` in the specified directory.

[Example](build.sh)

## Run the container

Use `docker run` to run the container.

`-w` sets the working directory in the container's file system.

`-v` mounts a volume (directory or file), which is like a mapped network drive. The docker container has read/write access to this directory on the host machine.

The `docker run` command includes the commands you want to run in the container.

[ Example](run.sh)

You can also run a container [interactively](interactive.sh).
6 changes: 6 additions & 0 deletions docker/interactive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# sudo docker run -it rocrate-preview:latest
sudo docker run -v /home/mbexegc2/projects/esciencelab/rocrate-to-pages/ro-crate-metadata.json:/tmp/ro-crate-metadata.json \
-w /tmp \
-it \
rocrate-preview:latest

5 changes: 5 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sudo docker run -v /home/mbexegc2/projects/esciencelab/rocrate-to-pages/ro-crate-metadata.json:/tmp/ro-crate-metadata.json \
-w /tmp \
-v /home/mbexegc2/projects/esciencelab/docker/output:/tmp/output \
rocrate-preview:latest \
bash -c $'rochtml ro-crate-metadata.json; mv ro-crate-preview.html /tmp/output'

0 comments on commit 4e9fb0d

Please sign in to comment.