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