Skip to content

WIP: Docker respin, GitLab CI #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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