From 4727a88de7d7cd039247bda255b028427eb15446 Mon Sep 17 00:00:00 2001 From: Mostafa Touny Date: Fri, 17 Jan 2025 23:02:42 +0200 Subject: [PATCH] any --- example/z-docker-opam/Dockerfile | 17 +++++++++++------ example/z-docker-opam/README.md | 21 ++++++++++++--------- example/z-docker-opam/deploy.sh | 8 -------- example/z-docker-opam/docker-compose.yml | 10 ---------- 4 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 example/z-docker-opam/deploy.sh delete mode 100644 example/z-docker-opam/docker-compose.yml diff --git a/example/z-docker-opam/Dockerfile b/example/z-docker-opam/Dockerfile index 09fd7b86..30177bf2 100644 --- a/example/z-docker-opam/Dockerfile +++ b/example/z-docker-opam/Dockerfile @@ -1,24 +1,29 @@ -FROM ocaml/opam:alpine as build +# Build Stage +# # # # # + +FROM ocaml/opam:alpine AS build # Install system dependencies -RUN sudo apk add --update libev-dev openssl-dev +RUN sudo apk add --update libev-dev openssl-dev gmp-dev WORKDIR /home/opam # Install dependencies -ADD hello.opam hello.opam +COPY z-docker-opam.opam z-docker-opam.opam RUN opam install . --deps-only # Build project -ADD . . +COPY . . RUN opam exec -- dune build +# Run Stage +# # # # # -FROM alpine:3.18.4 as run +FROM alpine:3.18.4 AS run RUN apk add --update libev COPY --from=build /home/opam/_build/default/app.exe /bin/app -ENTRYPOINT /bin/app +ENTRYPOINT [ "/bin/sh", "-c", "/bin/app" ] diff --git a/example/z-docker-opam/README.md b/example/z-docker-opam/README.md index 0ff4b0b3..befba1f6 100644 --- a/example/z-docker-opam/README.md +++ b/example/z-docker-opam/README.md @@ -2,16 +2,19 @@
-This example runs a simple Web app inside a [Docker](https://www.docker.com/) -container. It is a variant of [**`z-docker-esy`**](../z-docker-esy#folders-and-files), but -with [opam](https://opam.ocaml.org/) as the package manager. +This example runs a simple Web app inside a [Docker](https://www.docker.com/) container using [opam](https://opam.ocaml.org/) as the package manager. -All the instructions are the same as in -[**`z-docker-esy`**](../z-docker-esy#folders-and-files). The difference is in the -[`Dockerfile`](https://github.com/aantron/dream/blob/master/example/z-docker-opam/Dockerfile), -which, in this example, derives an image from one of the [opam base -images](https://hub.docker.com/r/ocaml/opam), and installs dependencies using -opam. The initial build requires at least 2 GB of memory. +Build the image from `Dockerfile` +``` +DOCKER_BUILDKIT=1 docker build . --tag "docker-opam-im" +``` + +create and run the container +``` +docker run --name docker-opam -p 8080:8080 docker-opam-im:latest +``` + +see also [**`z-docker-esy`**](../z-docker-esy#folders-and-files) for using `esy` package manager and `Docker compose`.
diff --git a/example/z-docker-opam/deploy.sh b/example/z-docker-opam/deploy.sh deleted file mode 100644 index b96f8168..00000000 --- a/example/z-docker-opam/deploy.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -e -set -x - -docker-compose build -docker-compose down -LOGGING_DRIVER=journald docker-compose up --detach diff --git a/example/z-docker-opam/docker-compose.yml b/example/z-docker-opam/docker-compose.yml deleted file mode 100644 index e96787df..00000000 --- a/example/z-docker-opam/docker-compose.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3" - -services: - web: - build: . - ports: - - "80:8080" - restart: always - logging: - driver: ${LOGGING_DRIVER:-json-file}