Skip to content
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

CI on Github Actions #718

Closed
wants to merge 14 commits into from
Closed
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
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on: [push] # FIXME: Temporarily avoid building PRs while setting up the CI

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set environment up
run: |
mv docker-compose.ci.yml docker-compose.override.yml
docker compose pull
docker compose up --wait db
docker compose build
docker compose exec db createdb planwise-test -U postgres
docker compose run --rm client npm install

- name: Run specs
env:
JVM_OPTS: -Xmx3200m
run: |
docker compose up --wait db
docker compose run --rm -e JVM_OPTS app lein test
docker compose run --rm client npm run test
docker compose run --rm app lein check-format

build:
needs: test
runs-on: ubuntu-22.04
env:
DOCKER_REPOSITORY: 'instedd/planwise'
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
steps:
- uses: actions/checkout@v4
- name: Build image & push to Docker Hub
run: ./build.sh
40 changes: 36 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
FROM clojure:lein-2.8.1 AS build

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

RUN apt update && \
apt install -y build-essential cmake \
libboost-timer-dev libboost-program-options-dev \
libboost-filesystem-dev \
libpq-dev libgdal-dev postgresql-client libpq-dev \
gdal-bin python-gdal libgdal-java \
&& \
curl -sL https://deb.nodesource.com/setup_9.x | bash - && \
apt-get install -y nodejs

WORKDIR /app

COPY . /app

RUN cd client && npm install && npm run release
RUN lein uberjar
RUN scripts/build-binaries --release

FROM openjdk:8u242-jre-stretch

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

# Install package dependencies and add precompiled binary
RUN for i in {1..5}; do \
(apt-get update \
Expand All @@ -10,18 +36,24 @@ RUN for i in {1..5}; do \
&& rm -rf /var/lib/apt/lists/*

# Add scripts
ADD scripts/ /app/scripts/
COPY --from=build /app/scripts/ /app/scripts/
ENV SCRIPTS_PATH /app/scripts/

# Add project compiled binaries
ADD cpp/build-linux-x86_64/aggregate-population /app/bin/aggregate-population
ADD cpp/build-linux-x86_64/walking-coverage /app/bin/walking-coverage
COPY --from=build /app/cpp/build-linux-x86_64/aggregate-population /app/bin/aggregate-population
COPY --from=build /app/cpp/build-linux-x86_64/walking-coverage /app/bin/walking-coverage
ENV BIN_PATH /app/bin/

# Add uberjar with app
ADD ./target/uberjar/planwise-standalone.jar /app/lib/
COPY --from=build /app/target/uberjar/planwise-standalone.jar /app/lib/
ENV JAR_PATH /app/lib/planwise-standalone.jar

# Add app version file
COPY --from=build /app/resources/planwise/version /app/VERSION

# Expose JNI libs to app
ENV LD_LIBRARY_PATH=/usr/lib/jni

# Exposed port
ENV PORT 80
EXPOSE $PORT
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM clojure:lein-2.8.1

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

RUN apt update && \
apt install -y build-essential cmake \
libboost-timer-dev libboost-program-options-dev \
Expand All @@ -11,4 +14,3 @@ RUN apt update && \
apt-get install -y nodejs

WORKDIR /app

13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -eo pipefail

source <(curl -s https://raw.githubusercontent.com/manastech/ci-docker-builder/d3406587def914918666ef41c0637d6b739fdf7d/build.sh)

dockerSetup
echo $VERSION > VERSION
echo $VERSION > resources/planwise/version

dockerBuildAndPush
# FIXME: build & push mapcache
# FIXME: build & push mapserver
# FIXME: build & push tools
3 changes: 0 additions & 3 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ version: '2'

services:
app:
volumes:
- .:/app
- ~/cache/.m2:/root/.m2
environment:
DATABASE_URL: "jdbc:postgresql://db/planwise?user=postgres&password=planwise"
TEST_DATABASE_URL: "jdbc:postgresql://db/planwise-test?user=postgres&password=planwise"
Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ services:
build:
dockerfile: Dockerfile-dev
context: .
platform: linux/amd64
volumes:
- ".:/app"
- m2:/root/.m2
- "~/.lein:/root/.lein"
links:
- "lein:/root/.lein"
depends_on:
- db
env_file:
- ./docker-env
Expand All @@ -22,6 +23,7 @@ services:
build:
dockerfile: Dockerfile-dev
context: .
platform: linux/amd64
volumes:
- ".:/app"
- m2:/root/.m2
Expand All @@ -46,7 +48,7 @@ services:
image: camptocamp/mapcache:1.4
volumes:
- "./mapserver/mapcache.xml:/mapcache/mapcache.xml:ro"
links:
depends_on:
- mapserver
ports:
- "5002:80"
Expand All @@ -61,16 +63,18 @@ services:

tools:
image: instedd/planwise-tools
platform: linux/amd64
build:
context: scripts
env_file:
- ./docker-env
volumes:
- "./data:/data"
links:
depends_on:
- db

volumes:
db:
lein:
m2:
node_modules: