From c96cc544e4022766c7048e064f10fd9cfef9c941 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sat, 9 Mar 2019 22:36:14 +0300 Subject: [PATCH] Add docker for building --- .dockerignore | 1 + .gitignore | 2 ++ Dockerfile | 5 +++++ Makefile | 37 +++++++++++++++++++++++++++++++++++++ haskell-cron-matcher.cabal | 6 +++--- stack.yaml | 9 +++++---- 6 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3a5b475 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.stack-work/ diff --git a/.gitignore b/.gitignore index 3a5b475..2bad1d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +.local/ .stack-work/ +*.sublime-* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3a7ef1a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM fpco/stack-build:lts-13.10 + +# Code formatter +# RUN stack --system-ghc --local-bin-path=/usr/local/bin install \ +# hfmt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d04aec0 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +app_name := haskell-cron-matcher +image := ${app_name}-stack + +container_work_dir := /app +cache_dir := ${container_work_dir}/.stack-work + +uid := $(shell id -u) +gid := $(shell id -g) + +stack := docker run \ + --rm \ + --tty \ + --init \ + --user "${uid}:${gid}" \ + --volume "${PWD}:${container_work_dir}" \ + --env "STACK_ROOT=${cache_dir}" \ + --workdir "${container_work_dir}" \ + ${image} + +# Targets + +.PHONY: build-docker +build-docker: + docker build --tag=${image} . + ${stack} stack --system-ghc --local-bin-path=./.local install hindent hfmt + +.PHONY: build +build: + ${stack} stack build + +.PHONY: test +test: + ${stack} stack test + +.PHONY: format +format: + ${stack} .local/hfmt -w src/ diff --git a/haskell-cron-matcher.cabal b/haskell-cron-matcher.cabal index 7c2da96..5e2262f 100644 --- a/haskell-cron-matcher.cabal +++ b/haskell-cron-matcher.cabal @@ -17,7 +17,7 @@ library hs-source-dirs: src exposed-modules: Pattern, Field, Constraint, Helper build-depends: base >= 4.7 && < 5 - , dates == 0.2.2.1 + , dates == 0.2.2.2 , text default-language: Haskell2010 @@ -26,7 +26,7 @@ executable haskell-cron-matcher-exe main-is: Main.hs ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Werror build-depends: base - , dates == 0.2.2.1 + , dates == 0.2.2.2 , parsec , haskell-cron-matcher default-language: Haskell2010 @@ -37,7 +37,7 @@ test-suite haskell-cron-matcher-test main-is: Spec.hs other-modules: PatternSpec, FieldSpec, ConstraintSpec, HelperSpec build-depends: base - , dates == 0.2.2.1 + , dates == 0.2.2.2 , hspec , QuickCheck , haskell-cron-matcher diff --git a/stack.yaml b/stack.yaml index 3b7c466..48d2823 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml" -resolver: lts-9.12 +resolver: lts-12.26 # User packages to be built. # Various formats can be used as shown in the example below. @@ -36,11 +36,12 @@ resolver: lts-9.12 # 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: - - dates-0.2.2.1 +extra-deps: + - dates-0.2.2.2 # Override default flag values for local packages and extra-deps flags: {}