Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OCluster to development docker #213

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,3 +1,4 @@
local-test-repo/.git
*.env
_build
_build
capnp-secrets
20 changes: 20 additions & 0 deletions cluster/Dockerfile
@@ -0,0 +1,20 @@
FROM ocaml/opam:debian-10-ocaml-4.12@sha256:9ce3fcbb65b4a23c56445d5c15e5009a37e904f0306586bbee57f8791a99f58c AS build
RUN sudo apt-get update && sudo apt-get install libev-dev capnproto m4 pkg-config libsqlite3-dev libgmp-dev libffi-dev -y --no-install-recommends
RUN cd ~/opam-repository && git pull origin -q master && git reset --hard 9935f57dd3f9722e6ca803aeb232b49d7058abf8 && opam update
RUN mkdir src && cd src && git clone 'https://github.com/ocurrent/ocluster' && opam pin -yn ocluster
RUN cd src && git clone 'https://github.com/ocurrent/obuilder' && opam pin -yn obuilder
WORKDIR src/ocluster
RUN opam install -y --deps-only .
RUN opam config exec -- dune build \
./_build/install/default/bin/ocluster-scheduler \
./_build/install/default/bin/ocluster-admin

FROM debian:10
RUN apt-get update && apt-get install libev4 libsqlite3-0 -y --no-install-recommends
RUN apt-get install ca-certificates -y # https://github.com/mirage/ocaml-conduit/issues/388
WORKDIR /var/lib/ocluster-scheduler
ENTRYPOINT ["/usr/local/bin/ocluster-scheduler"]
COPY --from=build \
/home/opam/src/ocluster/_build/install/default/bin/ocluster-scheduler \
/home/opam/src/ocluster/_build/install/default/bin/ocluster-admin \
/usr/local/bin/
24 changes: 21 additions & 3 deletions environments/development.docker-compose.yaml
Expand Up @@ -66,14 +66,16 @@ services:
volumes:
# Mount the source code of the test project to allow local testing.
- current-bench-data:/app/current-bench-data
- ../local-test-repo:/app/local-test-repo
- "${OCAML_BENCH_LOCAL_REPO?required}:${OCAML_BENCH_LOCAL_REPO?required}"
- /var/run/docker.sock:/var/run/docker.sock
- ../pipeline/db/migrations:/app/db/migrations
ports: ["${OCAML_BENCH_PIPELINE_PORT?required}:${OCAML_BENCH_PIPELINE_PORT?required}"]
- ../capnp-secrets:/app/capnp-secrets
ports:
- "${OCAML_BENCH_PIPELINE_PORT?required}:${OCAML_BENCH_PIPELINE_PORT?required}"
command:
- "current-bench-pipeline"
- "local"
- "/app/local-test-repo"
- "${OCAML_BENCH_LOCAL_REPO?required}"
- "--verbose"
- "--port=${OCAML_BENCH_PIPELINE_PORT?required}"
- "--docker-cpu=${OCAML_BENCH_DOCKER_CPU?required}"
Expand All @@ -83,8 +85,24 @@ services:
depends_on:
db:
condition: service_healthy
cluster:
condition: service_started
environment:
OCAML_BENCH_FRONTEND_URL: ${OCAML_BENCH_FRONTEND_URL?required}
cluster:
build:
context: ../cluster
command:
- "--capnp-secret-key-file=./capnp-secrets/key.pem"
- "--capnp-listen-address=tcp:0.0.0.0:${OCAML_BENCH_CLUSTER_PORT?required}"
- "--capnp-public-address=tcp:cluster:${OCAML_BENCH_CLUSTER_PORT?required}"
- "--state-dir=/var/lib/ocluster-scheduler"
- "--pools=${OCAML_BENCH_CLUSTER_POOLS}"
- "--verbose"
ports: ["${OCAML_BENCH_CLUSTER_PORT?required}:${OCAML_BENCH_CLUSTER_PORT?required}"]
volumes:
# Allow access to capnp secrets required by client and workers
- ../capnp-secrets:/var/lib/ocluster-scheduler/capnp-secrets
# Apply database migrations. To be used only in development!
db-migrate:
image: current-bench_pipeline:latest
Expand Down
3 changes: 3 additions & 0 deletions environments/development.env.template
Expand Up @@ -10,3 +10,6 @@ OCAML_BENCH_GRAPHQL_PORT=8080
OCAML_BENCH_PIPELINE_URL=http://localhost:8081
OCAML_BENCH_PIPELINE_PORT=8081
OCAML_BENCH_MULTICORE_REPOSITORIES=local/local
OCAML_BENCH_CLUSTER_PORT=9000
OCAML_BENCH_CLUSTER_POOLS=linux
OCAML_BENCH_LOCAL_REPO=/home/to/absolute/path/current-bench/local-test-repo
3 changes: 3 additions & 0 deletions pipeline/Dockerfile
Expand Up @@ -56,4 +56,7 @@ ENV PATH="/app/bin:${PATH}"
COPY ./aslr_seccomp.json /app/aslr_seccomp.json
COPY ./db/migrations /app/db/migrations
COPY --from=build /home/opam/.opam/4.13/bin/omigrate /app/bin/omigrate
COPY --from=build /home/opam/.opam/4.13/bin/ocluster-admin /app/bin/ocluster-admin
COPY --from=build /mnt/project/_build/default/bin/main.exe /app/bin/current-bench-pipeline
COPY ./entrypoint.sh /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
18 changes: 18 additions & 0 deletions pipeline/entrypoint.sh
@@ -0,0 +1,18 @@
#!/bin/sh

# wait for the cluster to generate the file
until [ -f /app/capnp-secrets/admin.cap ]
do
sleep 1
done

USER=current-bench-pipeline

# submission.cap is used to submit jobs to the workers
/app/bin/ocluster-admin --connect /app/capnp-secrets/admin.cap remove-client "$USER"
/app/bin/ocluster-admin --connect /app/capnp-secrets/admin.cap add-client "$USER" > /app/submission.cap

# give permission to workers
chmod -R a+rw /app/capnp-secrets

exec "$@"
1 change: 1 addition & 0 deletions pipeline/pipeline.opam
Expand Up @@ -29,6 +29,7 @@ depends: [
"postgresql"
"rresult"
"omigrate"
"ocluster"
]
pin-depends: [
[ "current.dev" "git+https://github.com/ocurrent/ocurrent.git#739c80bfda5290e6b0b854372db60789ac83ec97"]
Expand Down