Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.calva
.lsp
tmp
tmp-*
.lein-env
.nrepl-port
*.md
!README*.md
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ pom.xml.asc
/test-resources/pcp.edn
/data
/musketeers.js
/test.js
/test.js
.calva/
.lsp
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Multi stage image for building pcp
# Stage 1: build pcp
FROM ghcr.io/graalvm/graalvm-ce:java8-21.0.0.2 as build

RUN curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein --output /usr/local/bin/lein && \
chmod a+x /usr/local/bin/lein && \
gu install native-image

COPY . /app-src
WORKDIR /app-src

RUN bash build.sh && \
ls -la target/

# Stage 2: final image
FROM adoptopenjdk:8-jre-hotspot-focal

COPY --from=build /app-src/target/pcp* /usr/local/bin/
COPY docker-entrypoint.sh /docker-entrypoint.sh

COPY resources/pcp-templates /usr/share/pcp-site

EXPOSE 9000
EXPOSE 3000

CMD ["/docker-entrypoint.sh"]
15 changes: 15 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#

# turn on bash's job control
set -m

# Start the primary process and put it in the background
java -jar /usr/local/bin/pcp-server.jar &

# Start the helper process
/usr/local/bin/pcp -s /usr/share/pcp-site

# now we bring the primary process back into the foreground
# and leave it there
fg %1
44 changes: 44 additions & 0 deletions docs/pcp-container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Running PCP using containers

You can run `pcp` using container orchestrators

* Docker
* podman
* [TODO] Kubernetes

## Building container image using docker/podman


```sh
# Build the pcp container
docker build -t pcp .
```

## Using pcp container

You can run the container as is:

```sh
# Use the container using the default site
docker run --rm -ti -p 3000:3000 pcp

# Mount your site in the container. Once it starts, you can edit files and refresh.
docker run --rm -ti -p 3000:3000 -v examples/netdava-test/public:/usr/share/pcp-site pcp
```

You can build a custom container from pcp with your site.

```sh

cat > mysite.dockerfile << EOF
FROM pcp:latest
COPY my-webiste /usr/share/pcp-site
EOF

# Build the custom image
docker build -t my-pcp-site:latest -f mysite.dockerfile .
# Run your website

docker run --name my-pcp-site -p 3000:3000 my-pcp-site:latest
```

3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
:uberjar-name "pcp.jar"}
:test {:env {:my-passphrase "s3cr3t-p455ph4r3"
:pcp-template-path "resources/pcp-templates"}}
:dev {:dependencies [[eftest/eftest "0.5.9"]]
:dev {:dependencies [[eftest/eftest "0.5.9"]
[org.slf4j/slf4j-simple "1.7.32"]]
:plugins [[lein-shell "0.5.0"]]
:env {:my-passphrase "s3cr3t-p455ph4r3"}}}
:aliases
Expand Down