From 6b338fe9b0daf78573f6b20b1c1a444c155b5a06 Mon Sep 17 00:00:00 2001 From: Peter Salvatore Date: Fri, 1 May 2020 08:10:01 +0500 Subject: [PATCH 1/2] Add GHC 8.10.1, update Cabal, Stack, Debian base. Expand support matrix to include Debian Buster in addition to Stretch. The default Debian base will be Buster for both 8.8.3 and 8.10.1 (8.6.5 getting dropped). The GitHub Actions will now build/test the full matrix for pull requests. Remove examples as they don't work and are unsupported. --- .github/workflows/ci.yml | 79 ++++-------- 8.10/buster/Dockerfile | 48 ++++++++ 8.10/stretch/Dockerfile | 48 ++++++++ 8.8/buster/Dockerfile | 48 ++++++++ 8.8/{ => stretch}/Dockerfile | 18 ++- examples/7.10/snap/.dockerignore | 1 - examples/7.10/snap/.ghci | 4 - examples/7.10/snap/Dockerfile | 19 --- examples/7.10/snap/site_key.txt | Bin 96 -> 0 bytes examples/7.10/snap/snap-example.cabal | 63 ---------- .../snap/snaplets/heist/templates/_login.tpl | 9 -- .../snaplets/heist/templates/_new_user.tpl | 5 - .../snap/snaplets/heist/templates/base.tpl | 13 -- .../snap/snaplets/heist/templates/index.tpl | 19 --- .../snap/snaplets/heist/templates/login.tpl | 3 - .../snaplets/heist/templates/new_user.tpl | 3 - .../snaplets/heist/templates/userform.tpl | 14 --- examples/7.10/snap/src/Application.hs | 31 ----- examples/7.10/snap/src/Main.hs | 114 ------------------ examples/7.10/snap/src/Site.hs | 89 -------------- examples/7.10/snap/static/screen.css | 26 ---- examples/7.8/snap/.ghci | 4 - examples/7.8/snap/Dockerfile | 21 ---- examples/7.8/snap/README.md | 16 --- examples/7.8/snap/server/.ghci | 4 - examples/7.8/snap/server/snap-example.cabal | 63 ---------- .../snaplets/heist/templates/_login.tpl | 9 -- .../snaplets/heist/templates/_new_user.tpl | 5 - .../server/snaplets/heist/templates/base.tpl | 13 -- .../server/snaplets/heist/templates/index.tpl | 19 --- .../server/snaplets/heist/templates/login.tpl | 3 - .../snaplets/heist/templates/new_user.tpl | 3 - .../snaplets/heist/templates/userform.tpl | 14 --- examples/7.8/snap/server/src/Application.hs | 31 ----- examples/7.8/snap/server/src/Main.hs | 114 ------------------ examples/7.8/snap/server/src/Site.hs | 89 -------------- examples/7.8/snap/server/static/screen.css | 26 ---- examples/8.0/servant-api/Dockerfile | 9 -- examples/8.0/servant-api/LICENSE | 30 ----- examples/8.0/servant-api/Setup.hs | 2 - examples/8.0/servant-api/app/Main.hs | 6 - examples/8.0/servant-api/servant-api.cabal | 45 ------- examples/8.0/servant-api/src/Lib.hs | 39 ------ examples/8.0/servant-api/stack.yaml | 66 ---------- examples/8.0/servant-api/test/Spec.hs | 2 - 45 files changed, 182 insertions(+), 1105 deletions(-) create mode 100644 8.10/buster/Dockerfile create mode 100644 8.10/stretch/Dockerfile create mode 100644 8.8/buster/Dockerfile rename 8.8/{ => stretch}/Dockerfile (73%) delete mode 100644 examples/7.10/snap/.dockerignore delete mode 100644 examples/7.10/snap/.ghci delete mode 100644 examples/7.10/snap/Dockerfile delete mode 100644 examples/7.10/snap/site_key.txt delete mode 100644 examples/7.10/snap/snap-example.cabal delete mode 100644 examples/7.10/snap/snaplets/heist/templates/_login.tpl delete mode 100644 examples/7.10/snap/snaplets/heist/templates/_new_user.tpl delete mode 100644 examples/7.10/snap/snaplets/heist/templates/base.tpl delete mode 100644 examples/7.10/snap/snaplets/heist/templates/index.tpl delete mode 100644 examples/7.10/snap/snaplets/heist/templates/login.tpl delete mode 100644 examples/7.10/snap/snaplets/heist/templates/new_user.tpl delete mode 100644 examples/7.10/snap/snaplets/heist/templates/userform.tpl delete mode 100644 examples/7.10/snap/src/Application.hs delete mode 100644 examples/7.10/snap/src/Main.hs delete mode 100644 examples/7.10/snap/src/Site.hs delete mode 100644 examples/7.10/snap/static/screen.css delete mode 100644 examples/7.8/snap/.ghci delete mode 100644 examples/7.8/snap/Dockerfile delete mode 100644 examples/7.8/snap/README.md delete mode 100644 examples/7.8/snap/server/.ghci delete mode 100644 examples/7.8/snap/server/snap-example.cabal delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/_login.tpl delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/base.tpl delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/index.tpl delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/login.tpl delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl delete mode 100644 examples/7.8/snap/server/snaplets/heist/templates/userform.tpl delete mode 100644 examples/7.8/snap/server/src/Application.hs delete mode 100644 examples/7.8/snap/server/src/Main.hs delete mode 100644 examples/7.8/snap/server/src/Site.hs delete mode 100644 examples/7.8/snap/server/static/screen.css delete mode 100644 examples/8.0/servant-api/Dockerfile delete mode 100644 examples/8.0/servant-api/LICENSE delete mode 100644 examples/8.0/servant-api/Setup.hs delete mode 100644 examples/8.0/servant-api/app/Main.hs delete mode 100644 examples/8.0/servant-api/servant-api.cabal delete mode 100644 examples/8.0/servant-api/src/Lib.hs delete mode 100644 examples/8.0/servant-api/stack.yaml delete mode 100644 examples/8.0/servant-api/test/Spec.hs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 416b157..2dfb41e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,68 +1,41 @@ name: Build and Smoke Test on: - push: + pull_request: + branches: + - master jobs: ci: if: github.repository == 'haskell/docker-haskell' timeout-minutes: 30 runs-on: ubuntu-18.04 + name: ${{ matrix.ghc }}-${{ matrix.deb }} strategy: fail-fast: false matrix: - ghc: [8.6.5, 8.8.2, 8.8.3] + ghc: ['8.8.3', '8.10.1'] + deb: ['stretch', 'buster'] include: - - ghc: 8.6.5 - ghc_minor: 8.6 - - ghc: 8.8.2 - ghc_minor: 8.8 - - ghc: 8.8.3 - ghc_minor: 8.8 + - ghc: '8.8.3' + ghc_minor: '8.8' + - ghc: '8.10.1' + ghc_minor: '8.10' steps: - - uses: actions/checkout@v2 - - name: docker build [${{ matrix.ghc }}] - uses: nick-invision/retry@v1 - with: - timeout_minutes: 8 - max_attempts: 3 - command: docker build --pull --build-arg GHC=${{ matrix.ghc }} -t haskell:${{ matrix.ghc }} ${{ matrix.ghc_minor }} - - uses: actions/checkout@v2 - with: - repository: docker-library/official-images - path: official-images - - name: run official-images tests - run: ./official-images/test/run.sh haskell:${{ matrix.ghc }} + - uses: actions/checkout@v2 + - name: docker build [${{ matrix.ghc }}] + uses: nick-invision/retry@v1 + with: + timeout_minutes: 8 + max_attempts: 3 + command: | + docker build --pull \ + -t haskell:${{ matrix.ghc }}-${{ matrix.deb }} \ + ${{ matrix.ghc_minor }}/${{ matrix.deb }} + - uses: actions/checkout@v2 + with: + repository: docker-library/official-images + path: official-images + - name: run official-images tests + run: ./official-images/test/run.sh haskell:${{ matrix.ghc }}-${{ matrix.deb }} - ci-self-hosted: - if: github.repository == 'psftw/docker-haskell-private' - timeout-minutes: 20 - runs-on: self-hosted - strategy: - fail-fast: false - matrix: - ghc: [8.6.5, 8.8.2, 8.8.3] - include: - - ghc: 8.6.5 - ghc_minor: 8.6 - - ghc: 8.8.2 - ghc_minor: 8.8 - - ghc: 8.8.3 - ghc_minor: 8.8 - steps: - - uses: actions/checkout@v2 - - name: docker build [${{ matrix.ghc }}] - run: docker build --pull --build-arg GHC=${{ matrix.ghc }} -t haskell:${{ matrix.ghc }} ${{ matrix.ghc_minor }} - - name: check for cabal-cache - run: | - docker volume inspect cabal-cache-${{ matrix.ghc }} &> /dev/null || \ - docker run -t --rm -v cabal-cache-${{ matrix.ghc }}:/root/.cabal haskell:${{ matrix.ghc }} cabal new-update - - name: cabal new-install - run: docker run -t --rm -v cabal-cache-${{ matrix.ghc }}:/root/.cabal haskell:${{ matrix.ghc }} cabal new-install --lib primitive - - name: wipe stack cache - run: docker volume rm stack-test-${{ matrix.ghc }} - continue-on-error: true - - name: stack new - run: docker run -t --rm -v stack-test-${{ matrix.ghc }}:/stack -w /stack haskell:${{ matrix.ghc }} stack --resolver ghc-${{ matrix.ghc }} new testproject --bare - - name: stack run - run: docker run -t --rm -v stack-test-${{ matrix.ghc }}:/stack -w /stack haskell:${{ matrix.ghc }} stack run diff --git a/8.10/buster/Dockerfile b/8.10/buster/Dockerfile new file mode 100644 index 0000000..4b60462 --- /dev/null +++ b/8.10/buster/Dockerfile @@ -0,0 +1,48 @@ +FROM debian:buster + +RUN apt-get update && \ + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr && \ + rm -rf /var/lib/apt/lists/* + +ARG GHC=8.10.1 +ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 +ARG CABAL_INSTALL=3.2 +ARG STACK=2.3.1 +ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442 +ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D + +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \ + gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \ + gpgconf --kill all && \ + echo 'deb http://downloads.haskell.org/debian buster main' > /etc/apt/sources.list.d/ghc.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + cabal-install-${CABAL_INSTALL} \ + curl \ + g++ \ + ghc-${GHC} \ + git \ + libsqlite3-dev \ + libtinfo-dev \ + make \ + netbase \ + openssh-client \ + xz-utils \ + zlib1g-dev && \ + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* + +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_KEY} && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_RELEASE_KEY} && \ + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \ + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \ + gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \ + tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 && \ + /usr/local/bin/stack config set system-ghc --global true && \ + /usr/local/bin/stack config set install-ghc --global false && \ + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz + +ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH + +CMD ["ghci"] diff --git a/8.10/stretch/Dockerfile b/8.10/stretch/Dockerfile new file mode 100644 index 0000000..d4a716e --- /dev/null +++ b/8.10/stretch/Dockerfile @@ -0,0 +1,48 @@ +FROM debian:stretch + +RUN apt-get update && \ + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr && \ + rm -rf /var/lib/apt/lists/* + +ARG GHC=8.10.1 +ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 +ARG CABAL_INSTALL=3.2 +ARG STACK=2.3.1 +ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442 +ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D + +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \ + gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \ + gpgconf --kill all && \ + echo 'deb http://downloads.haskell.org/debian stretch main' > /etc/apt/sources.list.d/ghc.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + cabal-install-${CABAL_INSTALL} \ + curl \ + g++ \ + ghc-${GHC} \ + git \ + libsqlite3-dev \ + libtinfo-dev \ + make \ + netbase \ + openssh-client \ + xz-utils \ + zlib1g-dev && \ + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* + +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_KEY} && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_RELEASE_KEY} && \ + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \ + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \ + gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \ + tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 && \ + /usr/local/bin/stack config set system-ghc --global true && \ + /usr/local/bin/stack config set install-ghc --global false && \ + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz + +ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH + +CMD ["ghci"] diff --git a/8.8/buster/Dockerfile b/8.8/buster/Dockerfile new file mode 100644 index 0000000..973da94 --- /dev/null +++ b/8.8/buster/Dockerfile @@ -0,0 +1,48 @@ +FROM debian:buster + +RUN apt-get update && \ + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr && \ + rm -rf /var/lib/apt/lists/* + +ARG GHC=8.8.3 +ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 +ARG CABAL_INSTALL=3.2 +ARG STACK=2.3.1 +ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442 +ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D + +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \ + gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \ + gpgconf --kill all && \ + echo 'deb http://downloads.haskell.org/debian buster main' > /etc/apt/sources.list.d/ghc.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + cabal-install-${CABAL_INSTALL} \ + curl \ + g++ \ + ghc-${GHC} \ + git \ + libsqlite3-dev \ + libtinfo-dev \ + make \ + netbase \ + openssh-client \ + xz-utils \ + zlib1g-dev && \ + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* + +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_KEY} && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_RELEASE_KEY} && \ + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \ + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \ + gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \ + tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 && \ + /usr/local/bin/stack config set system-ghc --global true && \ + /usr/local/bin/stack config set install-ghc --global false && \ + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz + +ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH + +CMD ["ghci"] diff --git a/8.8/Dockerfile b/8.8/stretch/Dockerfile similarity index 73% rename from 8.8/Dockerfile rename to 8.8/stretch/Dockerfile index ef2917e..0cb295c 100644 --- a/8.8/Dockerfile +++ b/8.8/stretch/Dockerfile @@ -5,10 +5,16 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* ARG GHC=8.8.3 -ARG STACK=2.1.3 -ARG CABAL_INSTALL=3.0 +ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 +ARG CABAL_INSTALL=3.2 +ARG STACK=2.3.1 +ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442 +ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D -RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 && \ +RUN export GNUPGHOME="$(mktemp -d)" && \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \ + gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \ + gpgconf --kill all && \ echo 'deb http://downloads.haskell.org/debian stretch main' > /etc/apt/sources.list.d/ghc.list && \ apt-get update && \ apt-get install -y --no-install-recommends \ @@ -24,11 +30,11 @@ RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 427CB69AAC9D00F2A43 openssh-client \ xz-utils \ zlib1g-dev && \ - rm -rf /var/lib/apt/lists/* + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* RUN export GNUPGHOME="$(mktemp -d)" && \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys C5705533DA4F78D8664B5DC0575159689BEFB442 && \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 2C6A674E85EE3FB896AFC9B965101FF31C5C154D && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_KEY} && \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys ${STACK_RELEASE_KEY} && \ curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \ curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \ gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \ diff --git a/examples/7.10/snap/.dockerignore b/examples/7.10/snap/.dockerignore deleted file mode 100644 index 1521c8b..0000000 --- a/examples/7.10/snap/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/examples/7.10/snap/.ghci b/examples/7.10/snap/.ghci deleted file mode 100644 index a882c32..0000000 --- a/examples/7.10/snap/.ghci +++ /dev/null @@ -1,4 +0,0 @@ -:set -isrc -:set -hide-package MonadCatchIO-mtl -:set -hide-package monads-fd -:set -XOverloadedStrings diff --git a/examples/7.10/snap/Dockerfile b/examples/7.10/snap/Dockerfile deleted file mode 100644 index ca58d81..0000000 --- a/examples/7.10/snap/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM haskell:7.10 - -WORKDIR /opt/server - -RUN cabal update - -# Add just the .cabal file to capture dependencies -COPY ./snap-example.cabal /opt/server/snap-example.cabal - -# Docker will cache this command as a layer, freeing us up to -# modify source code without re-installing dependencies -# (unless the .cabal file changes!) -RUN cabal install --only-dependencies -j4 - -# Add and Install Application Code -COPY . /opt/server -RUN cabal install - -CMD ["snap-example"] diff --git a/examples/7.10/snap/site_key.txt b/examples/7.10/snap/site_key.txt deleted file mode 100644 index 9ea55c06a3051e7726edb34fe1b108bef8d66903..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96 zcmV-m0H6PB{Z7h9#Ph`=qvz+N7gpwgZEr?hC@!=k2ct-{uS&6Iw)-@#oCGEja2kGB z>X0wVG9?c#B&(gwd+In7tzf8T1Muvq;Z>NOkgDw$$-C%$Kx@Kfz4%Vn0Mhxq)O%zN C$1!^V diff --git a/examples/7.10/snap/snap-example.cabal b/examples/7.10/snap/snap-example.cabal deleted file mode 100644 index 87af735..0000000 --- a/examples/7.10/snap/snap-example.cabal +++ /dev/null @@ -1,63 +0,0 @@ -Name: snap-example -Version: 0.1 -Synopsis: Project Synopsis Here -Description: Project Description Here -License: AllRightsReserved -Author: Author -Maintainer: maintainer@example.com -Stability: Experimental -Category: Web -Build-type: Simple -Cabal-version: >=1.2 - -Flag development - Description: Whether to build the server in development (interpreted) mode - Default: False - -Flag old-base - default: False - manual: False - -Executable snap-example - hs-source-dirs: src - main-is: Main.hs - - Build-depends: - bytestring >= 0.9.1 && < 0.11, - heist >= 0.14 && < 0.15, - MonadCatchIO-transformers >= 0.2.1 && < 0.4, - mtl >= 2 && < 3, - snap >= 0.13 && < 0.15, - snap-core >= 0.9 && < 0.10, - snap-server >= 0.9 && < 0.10, - snap-loader-static >= 0.9 && < 0.10, - text >= 0.11 && < 1.3, - time >= 1.1 && < 1.6, - xmlhtml >= 0.1 && < 0.3 - - if flag(old-base) - build-depends: - base >= 4 && < 4.4, - lens >= 3.7.6 && < 3.8 - else - build-depends: - base >= 4.4 && < 5, - lens >= 3.7.6 && < 4.13 - - if flag(development) - build-depends: - snap-loader-dynamic == 0.10.* - cpp-options: -DDEVELOPMENT - -- In development mode, speed is already going to suffer, so skip - -- the fancy optimization flags. Additionally, disable all - -- warnings. The hint library doesn't give an option to execute - -- compiled code when there were also warnings, so disabling - -- warnings allows quicker workflow. - ghc-options: -threaded -w - else - if impl(ghc >= 6.12.0) - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans -fno-warn-unused-do-bind - else - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans diff --git a/examples/7.10/snap/snaplets/heist/templates/_login.tpl b/examples/7.10/snap/snaplets/heist/templates/_login.tpl deleted file mode 100644 index b646e7c..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/_login.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

Snap Example App Login

- -

- -/login -Login - - -

Don't have a login yet? Create a new user

diff --git a/examples/7.10/snap/snaplets/heist/templates/_new_user.tpl b/examples/7.10/snap/snaplets/heist/templates/_new_user.tpl deleted file mode 100644 index 5a9a332..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/_new_user.tpl +++ /dev/null @@ -1,5 +0,0 @@ -

Register a new user

- -/new_user -Add User - diff --git a/examples/7.10/snap/snaplets/heist/templates/base.tpl b/examples/7.10/snap/snaplets/heist/templates/base.tpl deleted file mode 100644 index e4e8127..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/base.tpl +++ /dev/null @@ -1,13 +0,0 @@ - - - Snap web server - - - -
- - - -
- - diff --git a/examples/7.10/snap/snaplets/heist/templates/index.tpl b/examples/7.10/snap/snaplets/heist/templates/index.tpl deleted file mode 100644 index 370dad5..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/index.tpl +++ /dev/null @@ -1,19 +0,0 @@ - - - -

- This is a simple demo page served using - Heist - and the Snap web framework. -

- -

Congrats! You're logged in as ''

- -

Logout

-
- - - - - -
diff --git a/examples/7.10/snap/snaplets/heist/templates/login.tpl b/examples/7.10/snap/snaplets/heist/templates/login.tpl deleted file mode 100644 index 29dc2fe..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/login.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.10/snap/snaplets/heist/templates/new_user.tpl b/examples/7.10/snap/snaplets/heist/templates/new_user.tpl deleted file mode 100644 index aa0fe53..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/new_user.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.10/snap/snaplets/heist/templates/userform.tpl b/examples/7.10/snap/snaplets/heist/templates/userform.tpl deleted file mode 100644 index 0f8a8fc..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/userform.tpl +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - - - - - - - -
Login:
Password:
-
diff --git a/examples/7.10/snap/src/Application.hs b/examples/7.10/snap/src/Application.hs deleted file mode 100644 index 8378832..0000000 --- a/examples/7.10/snap/src/Application.hs +++ /dev/null @@ -1,31 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - ------------------------------------------------------------------------------- --- | This module defines our application's state type and an alias for its --- handler monad. -module Application where - ------------------------------------------------------------------------------- -import Control.Lens -import Snap.Snaplet -import Snap.Snaplet.Heist -import Snap.Snaplet.Auth -import Snap.Snaplet.Session - ------------------------------------------------------------------------------- -data App = App - { _heist :: Snaplet (Heist App) - , _sess :: Snaplet SessionManager - , _auth :: Snaplet (AuthManager App) - } - -makeLenses ''App - -instance HasHeist App where - heistLens = subSnaplet heist - - ------------------------------------------------------------------------------- -type AppHandler = Handler App App - - diff --git a/examples/7.10/snap/src/Main.hs b/examples/7.10/snap/src/Main.hs deleted file mode 100644 index cad1698..0000000 --- a/examples/7.10/snap/src/Main.hs +++ /dev/null @@ -1,114 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} - -{- - -NOTE: Don't modify this file unless you know what you are doing. If you are -new to snap, start with Site.hs and Application.hs. This file contains -boilerplate needed for dynamic reloading and is not meant for general -consumption. - -Occasionally if we modify the way the dynamic reloader works and you want to -upgrade, you might have to swap out this file for a newer version. But in -most cases you'll never need to modify this code. - --} -module Main where - ------------------------------------------------------------------------------- -import Control.Exception (SomeException, try) -import qualified Data.Text as T -import Snap.Http.Server -import Snap.Snaplet -import Snap.Snaplet.Config -import Snap.Core -import System.IO -import Site - -#ifdef DEVELOPMENT -import Snap.Loader.Dynamic -#else -import Snap.Loader.Static -#endif - - ------------------------------------------------------------------------------- --- | This is the entry point for this web server application. It supports --- easily switching between interpreting source and running statically compiled --- code. --- --- In either mode, the generated program should be run from the root of the --- project tree. When it is run, it locates its templates, static content, and --- source files in development mode, relative to the current working directory. --- --- When compiled with the development flag, only changes to the libraries, your --- cabal file, or this file should require a recompile to be picked up. --- Everything else is interpreted at runtime. There are a few consequences of --- this. --- --- First, this is much slower. Running the interpreter takes a significant --- chunk of time (a couple tenths of a second on the author's machine, at this --- time), regardless of the simplicity of the loaded code. In order to --- recompile and re-load server state as infrequently as possible, the source --- directories are watched for updates, as are any extra directories specified --- below. --- --- Second, the generated server binary is MUCH larger, since it links in the --- GHC API (via the hint library). --- --- Third, and the reason you would ever want to actually compile with --- development mode, is that it enables a faster development cycle. You can --- simply edit a file, save your changes, and hit reload to see your changes --- reflected immediately. --- --- When this is compiled without the development flag, all the actions are --- statically compiled in. This results in faster execution, a smaller binary --- size, and having to recompile the server for any code change. --- -main :: IO () -main = do - -- Depending on the version of loadSnapTH in scope, this either enables - -- dynamic reloading, or compiles it without. The last argument to - -- loadSnapTH is a list of additional directories to watch for changes to - -- trigger reloads in development mode. It doesn't need to include source - -- directories, those are picked up automatically by the splice. - (conf, site, cleanup) <- $(loadSnapTH [| getConf |] - 'getActions - ["snaplets/heist/templates"]) - - _ <- try $ httpServe conf site :: IO (Either SomeException ()) - cleanup - - ------------------------------------------------------------------------------- --- | This action loads the config used by this application. The loaded config --- is returned as the first element of the tuple produced by the loadSnapTH --- Splice. The type is not solidly fixed, though it must be an IO action that --- produces the same type as 'getActions' takes. It also must be an instance of --- Typeable. If the type of this is changed, a full recompile will be needed to --- pick up the change, even in development mode. --- --- This action is only run once, regardless of whether development or --- production mode is in use. -getConf :: IO (Config Snap AppConfig) -getConf = commandLineAppConfig defaultConfig - - ------------------------------------------------------------------------------- --- | This function generates the the site handler and cleanup action from the --- configuration. In production mode, this action is only run once. In --- development mode, this action is run whenever the application is reloaded. --- --- Development mode also makes sure that the cleanup actions are run --- appropriately before shutdown. The cleanup action returned from loadSnapTH --- should still be used after the server has stopped handling requests, as the --- cleanup actions are only automatically run when a reload is triggered. --- --- This sample doesn't actually use the config passed in, but more --- sophisticated code might. -getActions :: Config Snap AppConfig -> IO (Snap (), IO ()) -getActions conf = do - (msgs, site, cleanup) <- runSnaplet - (appEnvironment =<< getOther conf) app - hPutStrLn stderr $ T.unpack msgs - return (site, cleanup) diff --git a/examples/7.10/snap/src/Site.hs b/examples/7.10/snap/src/Site.hs deleted file mode 100644 index 13624f4..0000000 --- a/examples/7.10/snap/src/Site.hs +++ /dev/null @@ -1,89 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - ------------------------------------------------------------------------------- --- | This module is where all the routes and handlers are defined for your --- site. The 'app' function is the initializer that combines everything --- together and is exported by this module. -module Site - ( app - ) where - ------------------------------------------------------------------------------- -import Control.Applicative -import Data.ByteString (ByteString) -import Data.Monoid -import qualified Data.Text as T -import Snap.Core -import Snap.Snaplet -import Snap.Snaplet.Auth -import Snap.Snaplet.Auth.Backends.JsonFile -import Snap.Snaplet.Heist -import Snap.Snaplet.Session.Backends.CookieSession -import Snap.Util.FileServe -import Heist -import qualified Heist.Interpreted as I ------------------------------------------------------------------------------- -import Application - - ------------------------------------------------------------------------------- --- | Render login form -handleLogin :: Maybe T.Text -> Handler App (AuthManager App) () -handleLogin authError = heistLocal (I.bindSplices errs) $ render "login" - where - errs = maybe mempty splice authError - splice err = "loginError" ## I.textSplice err - - ------------------------------------------------------------------------------- --- | Handle login submit -handleLoginSubmit :: Handler App (AuthManager App) () -handleLoginSubmit = - loginUser "login" "password" Nothing - (\_ -> handleLogin err) (redirect "/") - where - err = Just "Unknown user or password" - - ------------------------------------------------------------------------------- --- | Logs out and redirects the user to the site index. -handleLogout :: Handler App (AuthManager App) () -handleLogout = logout >> redirect "/" - - ------------------------------------------------------------------------------- --- | Handle new user form submit -handleNewUser :: Handler App (AuthManager App) () -handleNewUser = method GET handleForm <|> method POST handleFormSubmit - where - handleForm = render "new_user" - handleFormSubmit = registerUser "login" "password" >> redirect "/" - - ------------------------------------------------------------------------------- --- | The application's routes. -routes :: [(ByteString, Handler App App ())] -routes = [ ("/login", with auth handleLoginSubmit) - , ("/logout", with auth handleLogout) - , ("/new_user", with auth handleNewUser) - , ("", serveDirectory "static") - ] - - ------------------------------------------------------------------------------- --- | The application initializer. -app :: SnapletInit App App -app = makeSnaplet "app" "An snaplet example application." Nothing $ do - h <- nestSnaplet "" heist $ heistInit "templates" - s <- nestSnaplet "sess" sess $ - initCookieSessionManager "site_key.txt" "sess" (Just 3600) - - -- NOTE: We're using initJsonFileAuthManager here because it's easy and - -- doesn't require any kind of database server to run. In practice, - -- you'll probably want to change this to a more robust auth backend. - a <- nestSnaplet "auth" auth $ - initJsonFileAuthManager defAuthSettings sess "users.json" - addRoutes routes - addAuthSplices h auth - return $ App h s a - diff --git a/examples/7.10/snap/static/screen.css b/examples/7.10/snap/static/screen.css deleted file mode 100644 index b052609..0000000 --- a/examples/7.10/snap/static/screen.css +++ /dev/null @@ -1,26 +0,0 @@ -html { - padding: 0; - margin: 0; - background-color: #ffffff; - font-family: Verdana, Helvetica, sans-serif; -} -body { - padding: 0; - margin: 0; -} -a { - text-decoration: underline; -} -a :hover { - cursor: pointer; - text-decoration: underline; -} -img { - border: none; -} -#content { - padding-left: 1em; -} -#info { - font-size: 60%; -} diff --git a/examples/7.8/snap/.ghci b/examples/7.8/snap/.ghci deleted file mode 100644 index a882c32..0000000 --- a/examples/7.8/snap/.ghci +++ /dev/null @@ -1,4 +0,0 @@ -:set -isrc -:set -hide-package MonadCatchIO-mtl -:set -hide-package monads-fd -:set -XOverloadedStrings diff --git a/examples/7.8/snap/Dockerfile b/examples/7.8/snap/Dockerfile deleted file mode 100644 index cf1ed5f..0000000 --- a/examples/7.8/snap/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM haskell:7.8 - -RUN cabal update - -# Add .cabal file -ADD ./server/snap-example.cabal /opt/server/snap-example.cabal - -# Docker will cache this command as a layer, freeing us up to -# modify source code without re-installing dependencies -RUN cd /opt/server && cabal install --only-dependencies -j4 - -# Add and Install Application Code -ADD ./server /opt/server -RUN cd /opt/server && cabal install - -# Add installed cabal executables to PATH -ENV PATH /root/.cabal/bin:$PATH - -# Default Command for Container -WORKDIR /opt/server -CMD ["snap-example"] \ No newline at end of file diff --git a/examples/7.8/snap/README.md b/examples/7.8/snap/README.md deleted file mode 100644 index 7eec9fa..0000000 --- a/examples/7.8/snap/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# docker-library snap-example - -## Build Example: - -``` -docker build -t hsnap . -``` - -## Run Example: - -This command will run the example interactively mapping port 8000 -in the container to 8000 on the host. - -``` -docker run -i -t -p 8000:8000 hsnap -``` \ No newline at end of file diff --git a/examples/7.8/snap/server/.ghci b/examples/7.8/snap/server/.ghci deleted file mode 100644 index a882c32..0000000 --- a/examples/7.8/snap/server/.ghci +++ /dev/null @@ -1,4 +0,0 @@ -:set -isrc -:set -hide-package MonadCatchIO-mtl -:set -hide-package monads-fd -:set -XOverloadedStrings diff --git a/examples/7.8/snap/server/snap-example.cabal b/examples/7.8/snap/server/snap-example.cabal deleted file mode 100644 index 70f24b5..0000000 --- a/examples/7.8/snap/server/snap-example.cabal +++ /dev/null @@ -1,63 +0,0 @@ -Name: snap-example -Version: 0.1 -Synopsis: Project Synopsis Here -Description: Project Description Here -License: AllRightsReserved -Author: Author -Maintainer: maintainer@example.com -Stability: Experimental -Category: Web -Build-type: Simple -Cabal-version: >=1.2 - -Flag development - Description: Whether to build the server in development (interpreted) mode - Default: False - -Flag old-base - default: False - manual: False - -Executable snap-example - hs-source-dirs: src - main-is: Main.hs - - Build-depends: - bytestring >= 0.9.1 && < 0.11, - heist >= 0.14 && < 0.15, - MonadCatchIO-transformers >= 0.2.1 && < 0.4, - mtl >= 2 && < 3, - snap >= 0.13 && < 0.15, - snap-core >= 0.9 && < 0.10, - snap-server >= 0.9 && < 0.10, - snap-loader-static >= 0.9 && < 0.10, - text >= 0.11 && < 1.3, - time >= 1.1 && < 1.6, - xmlhtml >= 0.1 && < 0.3 - - if flag(old-base) - build-depends: - base >= 4 && < 4.4, - lens >= 3.7.6 && < 3.8 - else - build-depends: - base >= 4.4 && < 5, - lens >= 3.7.6 && < 4.10 - - if flag(development) - build-depends: - snap-loader-dynamic == 0.10.* - cpp-options: -DDEVELOPMENT - -- In development mode, speed is already going to suffer, so skip - -- the fancy optimization flags. Additionally, disable all - -- warnings. The hint library doesn't give an option to execute - -- compiled code when there were also warnings, so disabling - -- warnings allows quicker workflow. - ghc-options: -threaded -w - else - if impl(ghc >= 6.12.0) - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans -fno-warn-unused-do-bind - else - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans diff --git a/examples/7.8/snap/server/snaplets/heist/templates/_login.tpl b/examples/7.8/snap/server/snaplets/heist/templates/_login.tpl deleted file mode 100644 index b646e7c..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/_login.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

Snap Example App Login

- -

- -/login -Login - - -

Don't have a login yet? Create a new user

diff --git a/examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl b/examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl deleted file mode 100644 index 5a9a332..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl +++ /dev/null @@ -1,5 +0,0 @@ -

Register a new user

- -/new_user -Add User - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/base.tpl b/examples/7.8/snap/server/snaplets/heist/templates/base.tpl deleted file mode 100644 index e4e8127..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/base.tpl +++ /dev/null @@ -1,13 +0,0 @@ - - - Snap web server - - - -
- - - -
- - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/index.tpl b/examples/7.8/snap/server/snaplets/heist/templates/index.tpl deleted file mode 100644 index 370dad5..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/index.tpl +++ /dev/null @@ -1,19 +0,0 @@ - - - -

- This is a simple demo page served using - Heist - and the Snap web framework. -

- -

Congrats! You're logged in as ''

- -

Logout

-
- - - - - -
diff --git a/examples/7.8/snap/server/snaplets/heist/templates/login.tpl b/examples/7.8/snap/server/snaplets/heist/templates/login.tpl deleted file mode 100644 index 29dc2fe..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/login.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl b/examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl deleted file mode 100644 index aa0fe53..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/userform.tpl b/examples/7.8/snap/server/snaplets/heist/templates/userform.tpl deleted file mode 100644 index 0f8a8fc..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/userform.tpl +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - - - - - - - -
Login:
Password:
-
diff --git a/examples/7.8/snap/server/src/Application.hs b/examples/7.8/snap/server/src/Application.hs deleted file mode 100644 index 8378832..0000000 --- a/examples/7.8/snap/server/src/Application.hs +++ /dev/null @@ -1,31 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - ------------------------------------------------------------------------------- --- | This module defines our application's state type and an alias for its --- handler monad. -module Application where - ------------------------------------------------------------------------------- -import Control.Lens -import Snap.Snaplet -import Snap.Snaplet.Heist -import Snap.Snaplet.Auth -import Snap.Snaplet.Session - ------------------------------------------------------------------------------- -data App = App - { _heist :: Snaplet (Heist App) - , _sess :: Snaplet SessionManager - , _auth :: Snaplet (AuthManager App) - } - -makeLenses ''App - -instance HasHeist App where - heistLens = subSnaplet heist - - ------------------------------------------------------------------------------- -type AppHandler = Handler App App - - diff --git a/examples/7.8/snap/server/src/Main.hs b/examples/7.8/snap/server/src/Main.hs deleted file mode 100644 index cad1698..0000000 --- a/examples/7.8/snap/server/src/Main.hs +++ /dev/null @@ -1,114 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} - -{- - -NOTE: Don't modify this file unless you know what you are doing. If you are -new to snap, start with Site.hs and Application.hs. This file contains -boilerplate needed for dynamic reloading and is not meant for general -consumption. - -Occasionally if we modify the way the dynamic reloader works and you want to -upgrade, you might have to swap out this file for a newer version. But in -most cases you'll never need to modify this code. - --} -module Main where - ------------------------------------------------------------------------------- -import Control.Exception (SomeException, try) -import qualified Data.Text as T -import Snap.Http.Server -import Snap.Snaplet -import Snap.Snaplet.Config -import Snap.Core -import System.IO -import Site - -#ifdef DEVELOPMENT -import Snap.Loader.Dynamic -#else -import Snap.Loader.Static -#endif - - ------------------------------------------------------------------------------- --- | This is the entry point for this web server application. It supports --- easily switching between interpreting source and running statically compiled --- code. --- --- In either mode, the generated program should be run from the root of the --- project tree. When it is run, it locates its templates, static content, and --- source files in development mode, relative to the current working directory. --- --- When compiled with the development flag, only changes to the libraries, your --- cabal file, or this file should require a recompile to be picked up. --- Everything else is interpreted at runtime. There are a few consequences of --- this. --- --- First, this is much slower. Running the interpreter takes a significant --- chunk of time (a couple tenths of a second on the author's machine, at this --- time), regardless of the simplicity of the loaded code. In order to --- recompile and re-load server state as infrequently as possible, the source --- directories are watched for updates, as are any extra directories specified --- below. --- --- Second, the generated server binary is MUCH larger, since it links in the --- GHC API (via the hint library). --- --- Third, and the reason you would ever want to actually compile with --- development mode, is that it enables a faster development cycle. You can --- simply edit a file, save your changes, and hit reload to see your changes --- reflected immediately. --- --- When this is compiled without the development flag, all the actions are --- statically compiled in. This results in faster execution, a smaller binary --- size, and having to recompile the server for any code change. --- -main :: IO () -main = do - -- Depending on the version of loadSnapTH in scope, this either enables - -- dynamic reloading, or compiles it without. The last argument to - -- loadSnapTH is a list of additional directories to watch for changes to - -- trigger reloads in development mode. It doesn't need to include source - -- directories, those are picked up automatically by the splice. - (conf, site, cleanup) <- $(loadSnapTH [| getConf |] - 'getActions - ["snaplets/heist/templates"]) - - _ <- try $ httpServe conf site :: IO (Either SomeException ()) - cleanup - - ------------------------------------------------------------------------------- --- | This action loads the config used by this application. The loaded config --- is returned as the first element of the tuple produced by the loadSnapTH --- Splice. The type is not solidly fixed, though it must be an IO action that --- produces the same type as 'getActions' takes. It also must be an instance of --- Typeable. If the type of this is changed, a full recompile will be needed to --- pick up the change, even in development mode. --- --- This action is only run once, regardless of whether development or --- production mode is in use. -getConf :: IO (Config Snap AppConfig) -getConf = commandLineAppConfig defaultConfig - - ------------------------------------------------------------------------------- --- | This function generates the the site handler and cleanup action from the --- configuration. In production mode, this action is only run once. In --- development mode, this action is run whenever the application is reloaded. --- --- Development mode also makes sure that the cleanup actions are run --- appropriately before shutdown. The cleanup action returned from loadSnapTH --- should still be used after the server has stopped handling requests, as the --- cleanup actions are only automatically run when a reload is triggered. --- --- This sample doesn't actually use the config passed in, but more --- sophisticated code might. -getActions :: Config Snap AppConfig -> IO (Snap (), IO ()) -getActions conf = do - (msgs, site, cleanup) <- runSnaplet - (appEnvironment =<< getOther conf) app - hPutStrLn stderr $ T.unpack msgs - return (site, cleanup) diff --git a/examples/7.8/snap/server/src/Site.hs b/examples/7.8/snap/server/src/Site.hs deleted file mode 100644 index 13624f4..0000000 --- a/examples/7.8/snap/server/src/Site.hs +++ /dev/null @@ -1,89 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - ------------------------------------------------------------------------------- --- | This module is where all the routes and handlers are defined for your --- site. The 'app' function is the initializer that combines everything --- together and is exported by this module. -module Site - ( app - ) where - ------------------------------------------------------------------------------- -import Control.Applicative -import Data.ByteString (ByteString) -import Data.Monoid -import qualified Data.Text as T -import Snap.Core -import Snap.Snaplet -import Snap.Snaplet.Auth -import Snap.Snaplet.Auth.Backends.JsonFile -import Snap.Snaplet.Heist -import Snap.Snaplet.Session.Backends.CookieSession -import Snap.Util.FileServe -import Heist -import qualified Heist.Interpreted as I ------------------------------------------------------------------------------- -import Application - - ------------------------------------------------------------------------------- --- | Render login form -handleLogin :: Maybe T.Text -> Handler App (AuthManager App) () -handleLogin authError = heistLocal (I.bindSplices errs) $ render "login" - where - errs = maybe mempty splice authError - splice err = "loginError" ## I.textSplice err - - ------------------------------------------------------------------------------- --- | Handle login submit -handleLoginSubmit :: Handler App (AuthManager App) () -handleLoginSubmit = - loginUser "login" "password" Nothing - (\_ -> handleLogin err) (redirect "/") - where - err = Just "Unknown user or password" - - ------------------------------------------------------------------------------- --- | Logs out and redirects the user to the site index. -handleLogout :: Handler App (AuthManager App) () -handleLogout = logout >> redirect "/" - - ------------------------------------------------------------------------------- --- | Handle new user form submit -handleNewUser :: Handler App (AuthManager App) () -handleNewUser = method GET handleForm <|> method POST handleFormSubmit - where - handleForm = render "new_user" - handleFormSubmit = registerUser "login" "password" >> redirect "/" - - ------------------------------------------------------------------------------- --- | The application's routes. -routes :: [(ByteString, Handler App App ())] -routes = [ ("/login", with auth handleLoginSubmit) - , ("/logout", with auth handleLogout) - , ("/new_user", with auth handleNewUser) - , ("", serveDirectory "static") - ] - - ------------------------------------------------------------------------------- --- | The application initializer. -app :: SnapletInit App App -app = makeSnaplet "app" "An snaplet example application." Nothing $ do - h <- nestSnaplet "" heist $ heistInit "templates" - s <- nestSnaplet "sess" sess $ - initCookieSessionManager "site_key.txt" "sess" (Just 3600) - - -- NOTE: We're using initJsonFileAuthManager here because it's easy and - -- doesn't require any kind of database server to run. In practice, - -- you'll probably want to change this to a more robust auth backend. - a <- nestSnaplet "auth" auth $ - initJsonFileAuthManager defAuthSettings sess "users.json" - addRoutes routes - addAuthSplices h auth - return $ App h s a - diff --git a/examples/7.8/snap/server/static/screen.css b/examples/7.8/snap/server/static/screen.css deleted file mode 100644 index b052609..0000000 --- a/examples/7.8/snap/server/static/screen.css +++ /dev/null @@ -1,26 +0,0 @@ -html { - padding: 0; - margin: 0; - background-color: #ffffff; - font-family: Verdana, Helvetica, sans-serif; -} -body { - padding: 0; - margin: 0; -} -a { - text-decoration: underline; -} -a :hover { - cursor: pointer; - text-decoration: underline; -} -img { - border: none; -} -#content { - padding-left: 1em; -} -#info { - font-size: 60%; -} diff --git a/examples/8.0/servant-api/Dockerfile b/examples/8.0/servant-api/Dockerfile deleted file mode 100644 index 26715b2..0000000 --- a/examples/8.0/servant-api/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM haskell:8 - -COPY . /opt/servant-api - -WORKDIR /opt/servant-api - -RUN stack build - -CMD ["stack","exec","servant-api-exe"] diff --git a/examples/8.0/servant-api/LICENSE b/examples/8.0/servant-api/LICENSE deleted file mode 100644 index fc03544..0000000 --- a/examples/8.0/servant-api/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright Author name here (c) 2016 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Author name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/examples/8.0/servant-api/Setup.hs b/examples/8.0/servant-api/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/examples/8.0/servant-api/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/examples/8.0/servant-api/app/Main.hs b/examples/8.0/servant-api/app/Main.hs deleted file mode 100644 index f66a415..0000000 --- a/examples/8.0/servant-api/app/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Main where - -import Lib - -main :: IO () -main = startApp diff --git a/examples/8.0/servant-api/servant-api.cabal b/examples/8.0/servant-api/servant-api.cabal deleted file mode 100644 index 1e5adaf..0000000 --- a/examples/8.0/servant-api/servant-api.cabal +++ /dev/null @@ -1,45 +0,0 @@ -name: servant-api -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: https://github.com/githubuser/servant-api#readme -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2016 Author name here -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - , aeson - , servant-server - , wai - , warp - default-language: Haskell2010 - -executable servant-api-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , servant-api - default-language: Haskell2010 - -test-suite servant-api-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - build-depends: base - , servant-api - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -source-repository head - type: git - location: https://github.com/githubuser/servant-api diff --git a/examples/8.0/servant-api/src/Lib.hs b/examples/8.0/servant-api/src/Lib.hs deleted file mode 100644 index f985cc0..0000000 --- a/examples/8.0/servant-api/src/Lib.hs +++ /dev/null @@ -1,39 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeOperators #-} -module Lib - ( startApp - ) where - -import Data.Aeson -import Data.Aeson.TH -import Network.Wai -import Network.Wai.Handler.Warp -import Servant - -data User = User - { userId :: Int - , userFirstName :: String - , userLastName :: String - } deriving (Eq, Show) - -$(deriveJSON defaultOptions ''User) - -type API = "users" :> Get '[JSON] [User] - -startApp :: IO () -startApp = run 8080 app - -app :: Application -app = serve api server - -api :: Proxy API -api = Proxy - -server :: Server API -server = return users - -users :: [User] -users = [ User 1 "Isaac" "Newton" - , User 2 "Albert" "Einstein" - ] diff --git a/examples/8.0/servant-api/stack.yaml b/examples/8.0/servant-api/stack.yaml deleted file mode 100644 index d2ae7e0..0000000 --- a/examples/8.0/servant-api/stack.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# http://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# resolver: ghcjs-0.1.0_ghc-7.10.2 -# resolver: -# name: custom-snapshot -# location: "./custom-snapshot.yaml" -resolver: nightly-2016-06-15 - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# - location: -# git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# extra-dep: true -# subdirs: -# - auto-update -# - wai -# -# A package marked 'extra-dep: true' will only be built if demanded by a -# non-dependency (i.e. a user package), and its test suites and benchmarks -# will not be run. This is useful for tweaking upstream packages. -packages: -- '.' -# Dependency packages to be pulled from upstream that are not in the resolver -# (e.g., acme-missiles-0.3) -extra-deps: [] - -# Override default flag values for local packages and extra-deps -flags: {} - -# Extra package databases containing global packages -extra-package-dbs: [] - -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=1.1" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# extra-lib-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor \ No newline at end of file diff --git a/examples/8.0/servant-api/test/Spec.hs b/examples/8.0/servant-api/test/Spec.hs deleted file mode 100644 index cd4753f..0000000 --- a/examples/8.0/servant-api/test/Spec.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = putStrLn "Test suite not yet implemented" From 82f44382a183fcc1d0026d8abe58259195a8930c Mon Sep 17 00:00:00 2001 From: Peter Salvatore Date: Fri, 8 May 2020 11:10:40 -0400 Subject: [PATCH 2/2] Tweak Actions Workflow. --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dfb41e..05609e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: jobs: ci: - if: github.repository == 'haskell/docker-haskell' timeout-minutes: 30 runs-on: ubuntu-18.04 name: ${{ matrix.ghc }}-${{ matrix.deb }}