diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2e2a6d4 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +image: registry.gitlab.com/lorepub/moot/moot-build-image:latest + +stages: + - build + +cache: + key: global-cache + # key: ${CI_COMMIT_REF_SLUG} + paths: + - node_modules/ + - .stack-work/ + - /root/.stack/ + +build: + stage: build + script: | + make frontend-deps build + tags: + - moot diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b9d92d2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -sudo: false -language: generic - -services: - - postgresql - -addons: - apt: - packages: - - libgmp-dev - - postgresql-client - - postgresql-server-dev-all - - postgresql: "9.6" - -before_install: - - cd frontend - - npm install - - cd .. - -install: - # stack - - mkdir -p ~/.local/bin - - travis_retry curl -L https://github.com/commercialhaskell/stack/releases/download/v1.7.1/stack-1.7.1-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' - - export PATH=~/.local/bin:$PATH - - stack --no-terminal --version - - stack install happy - - stack install alex - # backend - - stack install yesod-bin - # test suite - - stack install hspec-discover - # database - - echo "CREATE USER moot WITH PASSWORD 'moot';" | psql postgres - - createdb -O moot moot - -# build frontend -before_script: - - cd frontend - - npm run-script build - - cd .. - -script: - - stack setup - - stack update - - stack build --fast -j1 - - stack test --fast - -cache: - timeout: 6000 - directories: - - $HOME/.cabal - - $HOME/.ghc - - $HOME/.stack - - .stack-work/ diff --git a/Dockerfile b/Dockerfile index be5eea8..11134e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,28 @@ FROM ubuntu:18.04 -# FROM fpco/stack-build:lts-12.2 ENV LANG=C.UTF-8 \ LC_ALL=C.UTF-8 \ - PATH=/moot/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUN apt-get update && \ apt-get install -y wget curl gnupg2 postgresql-server-dev-all postgresql-client && \ curl -sSL https://get.haskellstack.org/ | sh && \ rm -rf /var/lib/apt/lists/* -# setup node for building frontend -WORKDIR / +RUN stack setup --resolver lts-12.2 -RUN curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh && \ +RUN stack install --resolver lts-12.2 alex happy + +RUN stack build --resolver lts-12.2 yesod lens lens-aeson pandoc bcrypt email-validate errors basic-prelude xml-types foreign-store QuickCheck base-compat unix-compat HTTP-4000 temporary cpphs iproute wai \ + && stack clean + +RUN mkdir -p /builds/lorepub/moot +WORKDIR /builds/lorepub/moot + +RUN curl -sL https://deb.nodesource.com/setup_9.x -o nodesource_setup.sh && \ bash nodesource_setup.sh && \ apt-get install -y nodejs -WORKDIR /moot +COPY frontend/package.json package.json -ENV HOME /moot +RUN npm install -g gulp diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..e8103b6 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,39 @@ +FROM ubuntu:18.04 + +ENV LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +RUN apt-get update && \ + apt-get install -y wget curl gnupg2 postgresql-server-dev-all postgresql-client && \ + curl -sSL https://get.haskellstack.org/ | sh && \ + rm -rf /var/lib/apt/lists/* + +RUN stack setup --resolver lts-12.2 + +RUN stack install --resolver lts-12.2 alex happy + +RUN mkdir -p /builds/lorepub/moot +WORKDIR /builds/lorepub/moot + +RUN curl -sL https://deb.nodesource.com/setup_9.x -o nodesource_setup.sh && \ + bash nodesource_setup.sh && \ + apt-get install -y nodejs + +COPY frontend/package.json package.json + +RUN npm install -g gulp + +RUN addgroup --gid 1000 docker && \ + adduser --uid 1000 --ingroup docker --home /home/docker --shell /bin/sh --disabled-password --gecos "" docker + +# install fixuid +RUN USER=docker && \ + GROUP=docker && \ + curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.1/fixuid-0.1-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \ + chown root:root /usr/local/bin/fixuid && \ + chmod 4755 /usr/local/bin/fixuid && \ + mkdir -p /etc/fixuid && \ + printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml +USER docker:docker +ENTRYPOINT ["fixuid"] diff --git a/Makefile b/Makefile index 4392d73..2f09ee5 100644 --- a/Makefile +++ b/Makefile @@ -106,10 +106,14 @@ fixtures: build truncate-tables: build stack exec -- truncate +build-image: + sudo docker build -t moot-build-image . + sudo docker tag moot-build-image:latest registry.gitlab.com/lorepub/moot/moot-build-image:latest + docker-shell: - docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it $$(docker-compose ps -q moot_app) /bin/bash -c "reset -w && /bin/bash" + docker run -u 1000:1000 -v `pwd`:/builds/lorepub/moot -it moot-build-image /bin/bash -docker-pgshell: - docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it $$(docker-compose ps -q postgres) /bin/bash -c "reset -w && /bin/bash" +push-image: + sudo docker push registry.gitlab.com/lorepub/moot/moot-build-image -.PHONY : build build-dirty run install ghci test test-ghci ghcid dev-deps +.PHONY: build build-dirty run install ghci test test-ghci ghcid dev-deps build-image push-image