From a47bb20e44c0b4a684baa9f17935b2a9219eb086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20G=C3=89RARD?= Date: Mon, 6 Jan 2020 00:37:16 +0100 Subject: [PATCH] Deprecate nix dockerfile Former-commit-id: cddbcef37ebe9a8f683659d87ba195da429d0fdd Former-commit-id: 48764647f6e538039f3d383742e89c8839e99174 [formerly d333233a4eb32cbc7f90c18819ba3720e7043730] [formerly 7ca3407d95caae0b3103da1f1244c5483914f9de [formerly dff7c158337a0ae0bd98de7605ae859e244db4cd [formerly f8846510486f822294202a97b5b1ea3e25025e3e] [formerly f8846510486f822294202a97b5b1ea3e25025e3e [formerly f8846510486f822294202a97b5b1ea3e25025e3e [formerly 3a4793bd556c88c063419220faae4669427c8493]]]]] Former-commit-id: cf5d3444897186021d40396f4fb8daa820954890 [formerly f92cbca0cf854f50ee1cb7373492709444a8e5fd] Former-commit-id: e3edb9ae9523575907d858e4f401c70042486368 Former-commit-id: 1b62171a793c665623c0dfb8a97d3104809dcf42 Former-commit-id: 737061cd2adeea521e2f1cf31d434dc73f6a6c27 Former-commit-id: ea9fa483b758dfc15959d7e14207620032c3f844 [formerly 92993f8c81db2d474afddd03bd24f679245c8032] Former-commit-id: 07bfbcf39b8c0f452f7c06001d4a141815a0f01c --- .github/workflows/haskell.yml | 2 +- Dockerfile | 34 ++++++++++++++++++++++++++-------- Dockerfile.old | 34 ++++++++-------------------------- wstunnel.cabal | 1 + 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 3ec5b51..e354fa5 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -16,7 +16,7 @@ jobs: - name: Build run: | - docker build -t wstunnel -f Dockerfile.old . + docker build -t wstunnel . docker run --rm -v $(pwd):/data wstunnel /bin/cp wstunnel /data ./wstunnel diff --git a/Dockerfile b/Dockerfile index 347b804..3c97149 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,33 @@ -FROM nixos/nix as builder +FROM alpine:3.11 as builder MAINTAINER github@erebe.eu -RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs -RUN nix-channel --update -RUN nix-env -i bash upx +RUN apk --no-cache add ca-certificates git ghc curl musl-dev gmp-dev zlib-dev zlib-static pcre-dev xz make upx +RUN curl -sSL https://github.com/commercialhaskell/stack/releases/download/v2.1.3/stack-2.1.3-linux-x86_64-static.tar.gz | tar xvz && \ + mv stack*/stack /usr/bin + -WORKDIR /mnt COPY stack.yaml /mnt COPY *.cabal /mnt -COPY default.nix /mnt +WORKDIR /mnt +RUN rm -rf ~/.stack && \ + stack config set system-ghc --global true && \ + stack setup && \ + stack install --split-objs --ghc-options="-fPIC" --only-dependencies -RUN nix-build --no-link -A fullBuildScript COPY . /mnt -RUN $(nix-build --no-link -A fullBuildScript) + +RUN echo ' ld-options: -static' >> wstunnel.cabal ; \ + stack install --split-objs --ghc-options="-fPIC" +#RUN upx /root/.local/bin/wstunnel + + + +FROM alpine:latest as runner +MAINTAINER github@erebe.eu + +WORKDIR /root +COPY --from=builder /root/.local/bin/wstunnel . +RUN chmod +x ./wstunnel + +CMD ["./wstunnel"] + diff --git a/Dockerfile.old b/Dockerfile.old index 3c97149..347b804 100644 --- a/Dockerfile.old +++ b/Dockerfile.old @@ -1,33 +1,15 @@ -FROM alpine:3.11 as builder +FROM nixos/nix as builder MAINTAINER github@erebe.eu -RUN apk --no-cache add ca-certificates git ghc curl musl-dev gmp-dev zlib-dev zlib-static pcre-dev xz make upx -RUN curl -sSL https://github.com/commercialhaskell/stack/releases/download/v2.1.3/stack-2.1.3-linux-x86_64-static.tar.gz | tar xvz && \ - mv stack*/stack /usr/bin - +RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs +RUN nix-channel --update +RUN nix-env -i bash upx +WORKDIR /mnt COPY stack.yaml /mnt COPY *.cabal /mnt -WORKDIR /mnt -RUN rm -rf ~/.stack && \ - stack config set system-ghc --global true && \ - stack setup && \ - stack install --split-objs --ghc-options="-fPIC" --only-dependencies +COPY default.nix /mnt +RUN nix-build --no-link -A fullBuildScript COPY . /mnt - -RUN echo ' ld-options: -static' >> wstunnel.cabal ; \ - stack install --split-objs --ghc-options="-fPIC" -#RUN upx /root/.local/bin/wstunnel - - - -FROM alpine:latest as runner -MAINTAINER github@erebe.eu - -WORKDIR /root -COPY --from=builder /root/.local/bin/wstunnel . -RUN chmod +x ./wstunnel - -CMD ["./wstunnel"] - +RUN $(nix-build --no-link -A fullBuildScript) diff --git a/wstunnel.cabal b/wstunnel.cabal index a320d3e..4f28db0 100644 --- a/wstunnel.cabal +++ b/wstunnel.cabal @@ -32,6 +32,7 @@ library , text >= 1.2.2.1 , unordered-containers , websockets >= 0.12.4.0 + , iproute default-language: Haskell2010