Skip to content

Commit

Permalink
attempt to provide minimalist compose and images
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Sep 11, 2023
1 parent 9540f2a commit 2f4ffe8
Show file tree
Hide file tree
Showing 21 changed files with 159 additions and 438 deletions.
51 changes: 27 additions & 24 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
BASE_PROTOCOL="http"
HOST="localhost"

HTTP_PORT=8081
HTTPS_PORT=8083

POSTGRES_USER="geonatadmin"
POSTGRES_PASSWORD="geonatpasswd"
POSTGRES_HOST="postgres"
POSTGRES_DB="geonature2db"
POSTGRES_EXPOSED_PORT=5435

GDS_HTTP_PORT=8081
GDS_HTTPS_PORT=8083

HOST="localhost"
USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest"
USERSHUB_HOST="${HOST}:${HTTP_PORT}"
USERSHUB_PROTOCOL="${BASE_PROTOCOL}"
USERSHUB_DOMAIN="${HOST}"
USERSHUB_PREFIX="/usershub"
USERSHUB_SECRET_KEY="change me"

GDS_USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:develop"
GDS_USERSHUB_HOST="${HOST}:${GDS_HTTP_PORT}"
GDS_USERSHUB_DOMAIN="${HOST}"
GDS_USERSHUB_PREFIX="/usershub"
TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:latest"
TAXHUB_DOMAIN="${HOST}"
TAXHUB_PROTOCOL="${BASE_PROTOCOL}"
TAXHUB_HOST="${HOST}:${HTTP_PORT}"
TAXHUB_PREFIX="/taxhub"
TAXHUB_API_PREFIX="${TAXHUB_PREFIX}/api"

GDS_TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:develop"
GDS_TAXHUB_DOMAIN="${HOST}"
GDS_TAXHUB_HOST="${HOST}:${GDS_HTTP_PORT}"
GDS_TAXHUB_PREFIX="/taxhub"
GDS_TAXHUB_API_PREFIX="${GDS_TAXHUB_PREFIX}/api"
GDS_TAXHUB_PROTOCOL="http"
GEONATURE_DOMAIN="${HOST}"

GDS_GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend:develop"
GDS_GEONATURE_DOMAIN="${HOST}"
GDS_GEONATURE_BACKEND_HOST="${HOST}:${GDS_HTTP_PORT}"
GDS_GEONATURE_BACKEND_PREFIX="/geonature/api"
GDS_GEONATURE_BACKEND_PROTOCOL="http"
GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend-extended:latest"
GEONATURE_BACKEND_HOST="${HOST}:${HTTP_PORT}"
GEONATURE_BACKEND_PREFIX="/geonature/api"
GEONATURE_BACKEND_PROTOCOL="http"

GDS_GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend:develop"
GDS_GEONATURE_FRONTEND_HOST="${HOST}:${GDS_HTTP_PORT}"
GDS_GEONATURE_FRONTEND_PROTOCOL="http"
GDS_GEONATURE_FRONTEND_PREFIX="/geonature"
GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend-extended:latest"
GEONATURE_FRONTEND_HOST="${HOST}:${HTTP_PORT}"
GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}"
GEONATURE_FRONTEND_PREFIX="/geonature"
52 changes: 27 additions & 25 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
BASE_PROTOCOL="http"
HOST="example.com"

HTTP_PORT=80
HTTPS_PORT=443

POSTGRES_USER="geonatadmin"
POSTGRES_PASSWORD="geonatpasswd"
POSTGRES_HOST="postgres"
POSTGRES_DB="geonature2db"

GDS_HTTP_PORT=80
GDS_HTTPS_PORT=443

BASE_PROTOCOL="http"
HOST="localhost"
USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest"
USERSHUB_HOST="${HOST}"
USERSHUB_PROTOCOL="${BASE_PROTOCOL}"
USERSHUB_DOMAIN="${HOST}"
USERSHUB_PREFIX="/usershub"
USERSHUB_SECRET_KEY="change me"

GDS_USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest"
GDS_USERSHUB_HOST="${HOST}"
GDS_USERSHUB_PROTOCOL="${BASE_PROTOCOL}"
GDS_USERSHUB_DOMAIN="${HOST}"
GDS_USERSHUB_PREFIX="/usershub"
TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:latest"
TAXHUB_DOMAIN="${HOST}"
TAXHUB_PROTOCOL="${BASE_PROTOCOL}"
TAXHUB_HOST="${HOST}"
TAXHUB_PREFIX="/taxhub"
TAXHUB_API_PREFIX="${TAXHUB_PREFIX}/api"

GDS_TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:latest"
GDS_TAXHUB_DOMAIN="${HOST}"
GDS_TAXHUB_HOST="${HOST}"
GDS_TAXHUB_PREFIX="/taxhub"
GDS_TAXHUB_API_PREFIX="${GDS_TAXHUB_PREFIX}/api"
GDS_TAXHUB_PROTOCOL="${BASE_PROTOCOL}"
GEONATURE_DOMAIN="${HOST}"

GDS_GEONATURE_DOMAIN="${HOST}"
GDS_GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend:latest"
GDS_GEONATURE_BACKEND_HOST="${HOST}"
GDS_GEONATURE_BACKEND_PREFIX="/geonature/api"
GDS_GEONATURE_BACKEND_PROTOCOL="${BASE_PROTOCOL}"
GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend:latest"
GEONATURE_BACKEND_HOST="${HOST}"
GEONATURE_BACKEND_PREFIX="/geonature/api"
GEONATURE_BACKEND_PROTOCOL="${BASE_PROTOCOL}"

GDS_GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}"
GDS_GEONATURE_FRONTEND_HOST="${HOST}"
GDS_GEONATURE_FRONTEND_PREFIX="/geonature"
GDS_GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend:latest"
GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend:latest"
GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}"
GEONATURE_FRONTEND_HOST="${HOST}"
GEONATURE_FRONTEND_PREFIX="/geonature"
Binary file added .env.prod.swp
Binary file not shown.
188 changes: 23 additions & 165 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,122 +5,24 @@ on:
branches:
- main
- develop
- feat/prod
pull_request:
branches:
- develop
release:
types: [published]

jobs:
tests:
name: Build geonature images locally and test services
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: True

- name: Git GeoNature Sumbodule Update
run: |
git submodule init
git submodule update
working-directory: sources/GeoNature

- name: copy cur environment
run: cp .env.current .env

- name: Copy config samples
run: ./scripts/init_applications_config.sh

- name: Build all images
run: ./build/build_geonature_all.sh

- name: Lauch docker compose
run: docker compose up -d

- name: Log geonature backend
run: |
docker compose logs -f > /tmp/docker_compose.log &
- name: test geonature frontend response
uses: nick-fields/retry@v2
with:
timeout_seconds: 60
max_attempts: 10
retry_wait_seconds: 20
command: |
url_test="http://localhost:8081/geonature"
res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}")
echo $res
[ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1
- name: Test geonature backend response
uses: nick-fields/retry@v2
with:
timeout_seconds: 60
max_attempts: 15
retry_wait_seconds: 20
command: |
url_test="http://localhost:8081/geonature/api/gn_commons/config"
res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}")
echo $res
[ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1
- name: Test usershub response
uses: nick-fields/retry@v2
with:
timeout_seconds: 60
max_attempts: 3
retry_wait_seconds: 5
command: |
url_test="http://localhost:8081/usershub/login"
res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}")
echo $res
[ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1
- name: Test taxhub response
uses: nick-fields/retry@v2
with:
timeout_seconds: 60
max_attempts: 3
retry_wait_seconds: 5
command: |
url_test="http://localhost:8081/taxhub/"
res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}")
echo $res
[ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1
- name: Log if fail
if: ${{ failure() }}
run: |
cat /tmp/docker_compose.log
docker compose ps
backend:
name: Build geonature docker images for backend
name: Build geonature backend docker image
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: True

- name: Git GeoNature Sumbodule Update
run: |
git submodule init
git submodule update
working-directory: sources/GeoNature

- name: Set Environnement variables
run: |
scripts/init_env.sh >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -132,58 +34,33 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and export backend app image
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/backend/Dockerfile
tags: "${{env.GN_BACKEND_TAGS}}"
push: true
target: prod

- name: Build and export backend wheels image
uses: docker/build-push-action@v4
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/backend/Dockerfile
tags: "${{env.GN_BACKEND_TAGS}}-wheels"
push: true
target: wheels
images: ghcr.io/${{ github.repository_owner }}/geonature-backend-extra

- name: Build and export backend app + 4 modules
- name: Build and export image
uses: docker/build-push-action@v4
with:
context: .
file: ./build/Dockerfile-geonature-backend
tags: "${{env.GN_BACKEND_4M_TAGS}}"
labels: |
org.opencontainers.image.title=Application GeoNature + 4 modules principaux
org.opencontainers.image.description=${{env.GN_4M_DESCRIPTION}}
${{env.GN_LABELS}}
push: true
build-args: GDS_GEONATURE_BACKEND_IMAGE=${{env.GN_BACKEND_IMAGE}}
target: prod-extra
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: GEONATURE_BACKEND_IMAGE=ghcr.io/pnx-si/geonature-backend:2.13.0

frontend:
name: Build geonature docker images for frontend
name: Build geonature frontend docker image
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: True

- name: Git GeoNature Sumbodule Update
run: |
git submodule init
git submodule update
working-directory: ./sources/GeoNature

- name: Set Environnement variables
run: |
scripts/init_env.sh >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -195,38 +72,19 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and export frontend source
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/frontend/Dockerfile
target: source
tags: "${{env.GN_FRONTEND_TAGS}}-source"
push: true

- name: Build and export frontend nginx
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/frontend/Dockerfile
target: prod-base
tags: "${{env.GN_FRONTEND_TAGS}}-nginx"
push: true

- name: Build and export frontend app image
uses: docker/build-push-action@v4
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/frontend/Dockerfile
tags: "${{env.GN_FRONTEND_TAGS}}"
push: true
target: prod
images: ghcr.io/${{ github.repository_owner }}/geonature-backend-extra

- name: Build and export frontend + 4 modules
- name: Build and export image
uses: docker/build-push-action@v4
with:
context: .
file: ./build/Dockerfile-geonature-frontend
tags: "${{env.GN_FRONTEND_4M_TAGS}}"
build-args: GDS_GEONATURE_FRONTEND_IMAGE=${{env.GN_FRONTEND_IMAGE}}
push: true
target: prod-extra
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: GEONATURE_FRONTEND_IMAGE=ghcr.io/pnx-si/geonature-frontend:2.13.0
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.env
data/apps/*/config/*
data/apps/taxhub/static/*
data/apps/atlas/custom/*
data/apps/geonature/media/*
data/db/*
config/*
data/taxhub/static/*
data/geonature/media/*
!data/**/.gitkeep
!data/**/*.sample
*.swp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE EXTENSION IF NOT EXISTS "postgis";
CREATE EXTENSION IF NOT EXISTS "postgis_raster";
-- Note: postgis & postgis_raster are alreday created in postgis docker image

CREATE EXTENSION IF NOT EXISTS "hstore";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pg_trgm";
Expand Down
Loading

0 comments on commit 2f4ffe8

Please sign in to comment.