Commit e8bb0b84 authored by Yuanle Song's avatar Yuanle Song
Browse files

make code run in docker

- changed version to 1.0.0, it has been used in production for long.
- added Dockerfile
- added ./build-docker-image.sh script
- use lts-10.3 in stack.yaml
parent 7e099ab3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@ cabal.sandbox.config
.DS_Store
*.swp
*.keter
docker/get-client-ip

build-docker-image.sh

0 → 100755
+19 −0
Original line number Diff line number Diff line
#!/bin/sh

set -e

STACK_LOCAL_INSTALL_ROOT=`stack path --local-install-root`
EXE_FILE="${STACK_LOCAL_INSTALL_ROOT}/bin/get-client-ip"

stack build
if [ ! -e "$EXE_FILE" ]; then
	echo "Error: stack build failed" > /dev/stderr
	exit 1
fi

VERSION=`grep "^version:" get-client-ip.cabal | awk '{print $2}'`

ln -f "$EXE_FILE" docker/get-client-ip
docker build -t sylecn/get-client-ip:"$VERSION" docker/
echo "To publish this image, run"
echo "    docker push sylecn/get-client-ip:${VERSION}"

docker/Dockerfile

0 → 100644
+14 −0
Original line number Diff line number Diff line
FROM sylecn/debian:stretch-slim-cn

LABEL description="provides myip.emacsos.com service. allow client get its outgoing IP address. written in haskell scotty"

RUN set -x \
    && apt-get update \
    && apt-get install -y --no-install-recommends --no-install-suggests \
       libgmp10 \
       zlib1g \
    && rm -rf /var/lib/apt/lists/*
COPY get-client-ip /
CMD ["/get-client-ip"]

EXPOSE 8081
+2 −2
Original line number Diff line number Diff line
name:          get-client-ip
version:       0.1.1
version:       1.0.0
cabal-version: >= 1.8
build-type:    Simple

@@ -9,5 +9,5 @@ executable get-client-ip
    ghc-options:    -Wall -threaded -O2 -rtsopts -with-rtsopts=-N
    extensions:     OverloadedStrings
    build-depends:  base   >= 4      && < 5
                  , scotty >= 0.10.0 && < 0.11
                  , scotty
                  , text
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-3.0
resolver: lts-10.3

# Local packages, usually specified by relative directory name
packages: