Skip to content

Commit

Permalink
Add Docker files, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Phu2 committed Jun 7, 2024
1 parent 42f311d commit f544090
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM adoptopenjdk/openjdk11:debian

# Prepare nodejs install as leiningen requires nodejs
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash

RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
wget \
gnupg \
leiningen \
git \
vim \
nodejs \
&& \
apt clean && \
rm -rf /var/lib/apt/lists/*

# Use non-root user
ARG USERNAME=playground
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

USER $USERNAME

## metafacture-core
WORKDIR /opt/metafacture-core
RUN git clone https://github.com/metafacture/metafacture-core.git .
# use master for now, not a specific version
# must match dependencies in project.clj
#RUN git checkout metafacture-core-6.0.0
RUN ./gradlew install

## metafacture-fix
WORKDIR /opt/metafacture-fix
RUN git clone https://github.com/metafacture/metafacture-fix.git .
RUN git checkout 1.0.0
RUN ./gradlew install

## metafacture-playground
WORKDIR /opt/metafacture-playground
COPY --chown="$USERNAME:$USERNAME" ./ .

COPY --chown="$USERNAME:$USERNAME" resources/.java.policy_move_to_home_dir /home/$USERNAME/.java.policy

# enable debug mode
# by adding "-Djava.security.debug=access" option
# RUN sed 's/:jvm-opts \[/&"-Djava.security.debug=access" /' roles/metafacture-playground/files/project.clj

RUN lein release

CMD ["lein", "watch"]

# keep container running
#ENTRYPOINT ["tail", "-f", "/dev/null"]

# log into container:
# sudo docker exec -it metafacture-playground-app-1 bash
# inside the container:
# lein run > out 2>error
# or
# nohup lein run &
65 changes: 65 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM adoptopenjdk/openjdk11:debian

# Prepare nodejs install as leiningen requires nodejs
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash

RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
wget \
gnupg \
leiningen \
git \
vim \
nodejs \
&& \
apt clean && \
rm -rf /var/lib/apt/lists/*

# Use non-root user
ARG USERNAME=playground
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

USER $USERNAME

## metafacture-core
WORKDIR /opt/metafacture-core
RUN git clone https://github.com/metafacture/metafacture-core.git .
# use master for now, not a specific version
# must match dependencies in project.clj
#RUN git checkout metafacture-core-6.0.0
RUN ./gradlew install

## metafacture-fix
WORKDIR /opt/metafacture-fix
RUN git clone https://github.com/metafacture/metafacture-fix.git .
RUN git checkout 1.0.0
RUN ./gradlew install

## metafacture-playground
WORKDIR /opt/metafacture-playground
RUN git clone https://github.com/metafacture/metafacture-playground.git .

COPY --chown="$USERNAME:$USERNAME" resources/.java.policy_move_to_home_dir /home/$USERNAME/.java.policy

# enable debug mode
# by adding "-Djava.security.debug=access" option
# RUN sed 's/:jvm-opts \[/&"-Djava.security.debug=access" /' roles/metafacture-playground/files/project.clj

RUN lein release

CMD ["lein", "run"]

# keep container running
#ENTRYPOINT ["tail", "-f", "/dev/null"]

# log into container:
# sudo docker exec -it metafacture-playground-app-1 bash
# inside the container:
# lein run > out 2>error
# or
# nohup lein run &
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ Both deployments provide a web application and an HTTP API

[Here](CONTRIBUTING.md) you can read about contributing to Metafacture Playground.

## Docker

[Install Docker Engine](https://docs.docker.com/engine/install/) by follwing the guide for your distro.

[Install Docker Compose](https://docs.docker.com/compose/install/linux/#install-using-the-repository) as a plugin.

Alternatively, you may want to use the Docker Desktop environment which includes a GUI and all Docker components.

### Clone repo

```bash
git clone https://github.com/metafacture/metafacture-playground.git
cd metafacture-playground
```

### Start in development mode

```bash
docker compose -f docker-compose-dev.yml up
```

### Start in production mode

```bash
docker compose up
```

## Installation

Before starting you need to install [Leiningen](https://leiningen.org/) and a JDK (minimum Java 11).
Expand Down
9 changes: 9 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "2"

services:
app:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- 3000:3000
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2"

services:
app:
build:
context: .
dockerfile: Dockerfile.prod
ports:
- 3000:3000
mem_limit: 8192m
cpus: 0.5

0 comments on commit f544090

Please sign in to comment.