From c186ecf5214753ae82427654fa3395af408a1a52 Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 8 May 2021 19:22:12 +0200 Subject: [PATCH] Add Dockerfile and docker-compose example (#11) --- Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ Dockerfile.release | 19 +++++++++++++++++++ docker-compose.example.yaml | 17 +++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 Dockerfile create mode 100644 Dockerfile.release create mode 100644 docker-compose.example.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..624994b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM alpine:latest as build + +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +WORKDIR /tmp/haskell +RUN apk update && \ + apk upgrade --available && \ + apk add \ + build-base make cmake gcc gmp curl xz perl cpio coreutils \ + binutils-gold tar gzip unzip \ + libc-dev musl-dev ncurses-dev gmp-dev zlib-dev expat-dev libffi-dev \ + gd-dev postgresql-dev linux-headers + +RUN curl https://gitlab.haskell.org/haskell/ghcup-hs/raw/master/bootstrap-haskell -sSf | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh && \ + /root/.ghcup/bin/ghcup set +ENV PATH "$PATH:/root/.cabal/bin:/root/.ghcup/bin" + +WORKDIR /tmp/myriad +COPY . . +RUN cabal new-install + +RUN mkdir -p /opt/myriad && \ + cp -L /root/.cabal/bin/myriad /opt/myriad && \ + mv languages /opt/myriad && \ + mv config.example.yaml /opt/myriad/config.yaml + + +FROM alpine:latest +RUN apk add --no-cache docker-cli gmp +WORKDIR /opt/myriad +COPY --from=build /opt/myriad . + +EXPOSE 8081 + +CMD ["./myriad"] \ No newline at end of file diff --git a/Dockerfile.release b/Dockerfile.release new file mode 100644 index 0000000..95b951b --- /dev/null +++ b/Dockerfile.release @@ -0,0 +1,19 @@ +FROM frolvlad/alpine-glibc:latest as build + +ARG MYRIAD_VERSION=0.5.0.3 +ARG GHC_VERSION=8.8.3 + +RUN apk add --no-cache curl tar gzip +WORKDIR /tmp/myriad +RUN curl -OL https://github.com/1Computer1/myriad/releases/download/${MYRIAD_VERSION}/myriad-${MYRIAD_VERSION}-Linux-${GHC_VERSION}.tar.gz && \ + tar -xzf myriad-${MYRIAD_VERSION}-Linux-${GHC_VERSION}.tar.gz && \ + rm -f myriad-${MYRIAD_VERSION}-Linux-${GHC_VERSION}.tar.gz + +FROM frolvlad/alpine-glibc:latest +RUN apk add --no-cache docker-cli gmp +WORKDIR /opt/myriad +COPY --from=build /tmp/myriad . + +EXPOSE 8081 + +CMD ["./myriad"] \ No newline at end of file diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml new file mode 100644 index 0000000..9053dc8 --- /dev/null +++ b/docker-compose.example.yaml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + myriad: + build: + context: . + dockerfile: Dockerfile.release + image: myriad:latest + container_name: myriad + network_mode: bridge + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./config.yaml:/opt/myriad/config.yaml:ro + ports: + - 127.0.0.1:8081:8081/tcp + - ::1:8081:8081/tcp + restart: unless-stopped \ No newline at end of file