From c37e4aac541ccf9ff36e4eae6d023379c3134a9e Mon Sep 17 00:00:00 2001 From: Emi Mariscal Date: Thu, 30 Nov 2023 02:19:32 +0000 Subject: [PATCH] Revert "Merge: Optimise dockerfiles, fix ci, release images" --- .dockerignore | 22 ---- .github/workflows/release_img.yml | 29 ----- .github/workflows/tests.yml | 32 +++--- .github/workflows/tests/pr_payload.json | 10 -- .github/workflows/tests/push_payload.json | 4 - .github/workflows/tests/test_ci.sh | 19 ---- ci/ci_local.sh | 20 +++- docker-compose.yml | 42 +++---- docker/ci-entrypoint.sh | 40 ------- docker/underpass-api.dockerfile | 81 ++----------- docker/underpass-ui.dockerfile | 42 +------ docker/underpass.dockerfile | 131 +++++++--------------- docs/Dev/install-with-docker.md | 2 +- docs/get-started/Setup.md | 6 +- 14 files changed, 103 insertions(+), 377 deletions(-) delete mode 100644 .dockerignore delete mode 100644 .github/workflows/release_img.yml delete mode 100644 .github/workflows/tests/pr_payload.json delete mode 100644 .github/workflows/tests/push_payload.json delete mode 100644 .github/workflows/tests/test_ci.sh delete mode 100644 docker/ci-entrypoint.sh diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 2b9edd38..00000000 --- a/.dockerignore +++ /dev/null @@ -1,22 +0,0 @@ -# Ignore everything -** - -# Allow files and directories - -# Underpass -!src -!config -!setup -!docker/bzip2.pc -!autogen.sh -!configure.ac -!Makefile.am -!m4 -!dist -!docs -!ABOUT-NLS -!config.rpath -!docker/ci-entrypoint.sh - -# API -!python diff --git a/.github/workflows/release_img.yml b/.github/workflows/release_img.yml deleted file mode 100644 index dcf5ff67..00000000 --- a/.github/workflows/release_img.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: 🔧 Build Release Images - -on: - release: - types: [published] - # Allow manual trigger - workflow_dispatch: - -jobs: - underpass-build: - uses: hotosm/gh-workflows/.github/workflows/image_build.yml@1.1.2 - with: - dockerfile: docker/underpass.dockerfile - build_target: prod - image_name: ghcr.io/${{ github.repository }} - - api-build: - uses: hotosm/gh-workflows/.github/workflows/image_build.yml@1.1.2 - with: - dockerfile: docker/underpass-api.dockerfile - build_target: prod - image_name: ghcr.io/${{ github.repository }}/api - - ui-build: - uses: hotosm/gh-workflows/.github/workflows/image_build.yml@1.1.2 - with: - dockerfile: docker/underpass-ui.dockerfile - build_target: prod - image_name: ghcr.io/${{ github.repository }}/ui diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d05dd75b..9de44030 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,25 +1,29 @@ -name: 🧪 Build and Test +name: 🧪 Build and test on: push: branches: - master - pull_request: - branches: - - master paths: - src/** - .github/workflows/** - docker/** jobs: - build-and-test: - uses: hotosm/gh-workflows/.github/workflows/test_compose.yml@1.2.1 - with: - image_name: ghcr.io/${{ github.repository }} - build_dockerfile: docker/underpass.dockerfile - compose_service: underpass - compose_command: echo "Tests complete." - # TODO update postgis image to use github repo var ${{ vars.POSTGIS_TAG }} - cache_extra_imgs: | - "docker.io/postgis/postgis:15-3.3-alpine" + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + # Relies on the master branch built docker image for build-deps + - name: Start Docker Compose & build + run: cd docker && docker-compose up -d underpass + # Build and run tests + - name: Build and run tests + run: | + docker-compose -f docker-compose.yml exec -T underpass sh -c "cd /code/build && make check -j `nproc`" + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo "Test failed with exit code $exit_code" + exit $exit_code + fi \ No newline at end of file diff --git a/.github/workflows/tests/pr_payload.json b/.github/workflows/tests/pr_payload.json deleted file mode 100644 index 265abb8a..00000000 --- a/.github/workflows/tests/pr_payload.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "pull_request": { - "head": { - "ref": "feat/some-new-thing" - }, - "base": { - "ref": "master" - } - } -} diff --git a/.github/workflows/tests/push_payload.json b/.github/workflows/tests/push_payload.json deleted file mode 100644 index 07f80ac5..00000000 --- a/.github/workflows/tests/push_payload.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "base_ref ": "master", - "ref": "refs/heads/master" -} diff --git a/.github/workflows/tests/test_ci.sh b/.github/workflows/tests/test_ci.sh deleted file mode 100644 index a7572d5c..00000000 --- a/.github/workflows/tests/test_ci.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e - -######################################## -# Note: run this from the repo root. -######################################## - -# Tests -act pull_request -W .github/workflows/tests.yml \ - -e .github/workflows/tests/pr_payload.json - -# Docs -act push -W .github/workflows/docs.yml \ - -e .github/workflows/tests/pr_payload.json - -# Release -act release -W .github/workflows/release_img.yml \ - -e .github/workflows/tests/push_payload.json diff --git a/ci/ci_local.sh b/ci/ci_local.sh index 12c0dc4a..0213d434 100755 --- a/ci/ci_local.sh +++ b/ci/ci_local.sh @@ -19,12 +19,24 @@ cd ${TEMP_DIR} make distclean -j `nproc` || true make clean -j `nproc` || true -# Run CI -APP_VERSION=ci docker compose run underpass --exit-code-from=underpass +DOCKER_DIR="${TEMP_DIR}" +DOCKER_COMPOSE_FILE="${DOCKER_DIR}/docker-compose.yml" +DOCKER_BASE_COMMAND="docker-compose -f ${DOCKER_COMPOSE_FILE}" -# Shut down containers -APP_VERSION=ci docker compose down +# Run the composition +${DOCKER_BASE_COMMAND} up -d +# Build Underpass Library and Binaries +${DOCKER_BASE_COMMAND} exec -T underpass sh -c "cd /code && git clean -fx && git clean -f -d && ./autogen.sh && (rm -rf build || true) && mkdir build && cd build && ../configure --enable-shared && make -j `nproc`" + +# Build and Run Underpass Tests - broken: alway succeeds +${DOCKER_BASE_COMMAND} exec -T underpass sh -c "cd /code/build/src/testsuite/libunderpass.all && make check -j `nproc`" + +# Comment the cleanup lines below or exit here if you want to run additional +# tests from a console in the temp container, for instance with: +${DOCKER_BASE_COMMAND} exec underpass bash + +${DOCKER_BASE_COMMAND} down echo "Remove temporary folder ${TEMP_DIR}" sudo rm -rf ${TEMP_DIR} diff --git a/docker-compose.yml b/docker-compose.yml index 0a1ab552..4b74239c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,10 +22,11 @@ version: "3" services: # Database postgis: - image: postgis/postgis:${POSTGIS_TAG:-15-3.3-alpine} + image: postgis/postgis:15-3.3 + # image: arm64v8/postgres:15.3-alpine3.18 container_name: "underpass_postgis" ports: - - "${DB_PORT:-5439}:5432" + - "5439:5432" environment: - POSTGRES_DB=underpass - POSTGRES_USER=underpass @@ -43,61 +44,44 @@ services: # Underpass underpass: - image: "ghcr.io/hotosm/underpass:${APP_VERSION:-debug}" - container_name: underpass + container_name: "underpass" build: context: . dockerfile: docker/underpass.dockerfile - target: debug - args: - APP_VERSION: ${APP_VERSION:-debug} - depends_on: [postgis] environment: - REPLICATOR_UNDERPASS_DB_URL=underpass:underpass@postgis/underpass command: tail -f /dev/null volumes: - ./replication:/code/build/replication - # # Mount code # - ./:/code networks: internal: # Underpass API - api: - image: "ghcr.io/hotosm/underpass/api:${APP_VERSION:-debug}" - container_name: underpass_api + underpass-api: + container_name: "underpass_api" build: context: . dockerfile: docker/underpass-api.dockerfile - target: debug - args: - APP_VERSION: ${APP_VERSION:-debug} - depends_on: [underpass] - volumes: - - ./python:/code + # volumes: + # - ./python:/code/api ports: - - "${API_PORT:-8000}:8000" + - "8000:8000" networks: internal: environment: - UNDERPASS_API_DB=postgresql://underpass:underpass@postgis/underpass # Underpass UI - ui: - image: "ghcr.io/hotosm/underpass/ui:${APP_VERSION:-debug}" - container_name: underpass_ui + underpass-ui: + container_name: "underpass_ui" build: context: . dockerfile: docker/underpass-ui.dockerfile - target: debug - args: - APP_VERSION: ${APP_VERSION:-debug} - # # Mount underpass-ui repo # volumes: - # - ../underpass-ui/src:/code/src - # - ../underpass-ui/playground:/code/playground + # - js:/code ports: - - "${UI_PORT:-5000}:5000" + - "5000:5000" networks: internal: diff --git a/docker/ci-entrypoint.sh b/docker/ci-entrypoint.sh deleted file mode 100644 index 8556f8cb..00000000 --- a/docker/ci-entrypoint.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -yellow_echo() { - local message="$1" - local separator="--------------------------------------------------------" - local sep_length=${#separator} - local pad_length=$(( (sep_length - ${#message}) / 2 )) - local pad="" - - for ((i=0; i` and `-u ` for the database. - -For example, if you installed Underpass using Docker: - Regions (-r) are: africa