Commit 65133131 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Version Docker (Straling) - En cours

parent 22cb8536
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
# CONFIGURATION DOCKER

######################### POSTGRESQL
POSTGRESQL_USER=oscar
POSTGRESQL_BASE=oscar
POSTGRESQL_PASS=azerty
# Dossier où sera créée la base de donnée (fichiers)
POSTGRESQL_DATABASE_DIRECTORY=./databases

########################## OSCAR
# Emplacement racine des sources Oscar
OSCAR_SRC=./../../
+2 −0
Original line number Diff line number Diff line
databases
.env
 No newline at end of file
+108 −0
Original line number Diff line number Diff line
# OSCAR DOCKER [v Starling / démo]

## Prérequis

Les instructions ci-après ont été testées sur la version **27.x** de docker.

```bash
docker version
```

```text
Client: Docker Engine - Community
 Version:           27.2.1
 API version:       1.47
 Go version:        go1.22.7
 Git commit:        9e34c9b
 Built:             Fri Sep  6 12:08:06 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.2.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.7
  Git commit:       8b539b8
  Built:            Fri Sep  6 12:08:06 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.21
  GitCommit:        472731909fa34bd7bc9c087e4c27943f9835f111
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
```

## Récupération des sources
```bash
git clone https://git.unicaen.fr/open-source/oscar.git
cd oscar
```

## Copie des fichiers de base de configuration

Copiez les fichiers de configurations de base

```bash
cp dockerize/ripley-demo/oscar/oscar/config/autoload/local.php config/autoload/
cp dockerize/ripley-demo/oscar/oscar/config/autoload/unicaen-app.local.php config/autoload/
cp dockerize/ripley-demo/oscar/oscar/config/autoload/unicaen-auth.local.php config/autoload/
```

## Construction de l'application

Le *docker-compose.yml* est disponible dans les sources de l'application : `dockerize/starling-demo`

```bash
cd dockerize/ripley-demo
```

### Configuration

La configuration par défaut peut fonctionner directement. D'autres paramètres y seront ajouté progressivement. Principalement des paramètres métiers déstiner à tester des fonctionnalités impliquant des applications tiers.

```bash
# Copie de la configuration par défaut
cp .env.dist .env

# Edition de la configuration
nano .env
```

### Build des images

```bash
# Construction des images
sudo docker compose build
```

## Lancement de l'application

```bash
sudo docker compose up
```

Accès : http://localhost:8181

## Activer le compte administrateur

```bash
# Se connecter à oscar
sudo docker compose exec oscar_starling sh

# Une fois connecté
su

# Création de l'utilisateur
php bin/oscar.php auth:add

# Promotion "Administrateur"
php bin/oscar.php auth:promote
```

+150 −0
Original line number Diff line number Diff line
services:

  # --------------------------------------------------------------------------------------------------------------------
  # OSCAR (sources)
  oscar_starling:
    env_file:
      - .env
    depends_on:
      oscar_starling_elasticsearch:
        condition: service_healthy

    container_name: oscar_starling
    build:
        context: ./oscar/
        dockerfile: Dockerfile
        args:
            proxy_environnement: ""
            service_oscar_name: oscar_starling
            service_postgresql_name: oscar_starling_postgresql
            service_gearman_name: oscar_starling_gearman
            service_elasticsearch_name: oscar_starling_elasticsearch

    ports:
      - 8181:80
    volumes:
      - ${OSCAR_SRC}:/var/OscarApp
    networks:
      - oscar_starling_network
    tty: true
    restart: unless-stopped

  # --------------------------------------------------------------------------------------------------------------------
  # ELASTIC SEARCH
  oscar_starling_elasticsearch:
    container_name: oscar_starling_elasticsearch
    environment:
      - discovery.type=single-node
    build:
        context: ./elasticsearch/
        dockerfile: Dockerfile
        args:
          proxy_environnement: ""
          service_oscar_name: oscar_starling
          service_postgresql_name: oscar_starling_postgresql
          service_gearman_name: oscar_starling_gearman
    depends_on:
      oscar_starling_postgresql:
        condition: service_healthy
    healthcheck:
      test: [ "CMD-SHELL", "curl -fsSL http://oscar_starling_elasticsearch:9200/_cluster/health || exit 1" ]
      interval: 30s   # Intervalle entre chaque vérification
      timeout: 10s    # Temps limite d'attente de la réponse
      retries: 3

    networks:
      - oscar_starling_network
    tty: true
    restart: "always"

  # --------------------------------------------------------------------------------------------------------------------
  # POSTGRESQL
  oscar_starling_postgresql:
    env_file:
      - .env
    container_name: oscar_starling_postgresql
    build:
      context: ./postgresql/
      dockerfile: Dockerfile
      args:
        proxy_environnement: ""
        service_oscar_name: oscar_starling
        service_gearman_name: oscar_starling_gearman
        service_elasticsearch_name: oscar_starling_elasticsearch
        pathdatas: ${POSTGRESQL_DATABASE_DIRECTORY}
    environment:
      POSTGRES_PASSWORD: "azerty"
      POSTGRES_USER: "oscar"
      POSTGRES_DB: "oscar_dev"

    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U oscar -d oscar_dev" ]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

    networks:
      - oscar_starling_network
    tty: true
    volumes:
      - ${POSTGRESQL_DATABASE_DIRECTORY}:/var/lib/postgresql/data
    restart: "always"

  # ADMINERDEV
  oscar_starling_adminer:
    container_name: oscar_starling_adminer
    image: adminer
    restart: "always"
    ports:
      - 8182:8080
    networks:
      - oscar_starling_network
    tty: true


  # GEARMAN
  oscar_starling_gearman:
    container_name: oscar_starling_gearman
    build:
        context: ./gearman/
        dockerfile: Dockerfile
        args:
          proxy_environnement: ""
          service_oscar_name: oscar_starling
          service_postgresql_name: oscar_starling_postgresql
          service_elasticsearch_name: oscar_starling_elasticsearch
    networks:
      - oscar_starling_network
    tty: true
    restart: "unless-stopped"

  # MAILHOG (Ajout proposé par Joachim Dornbusch)
  oscar_starling_mailhog:
    container_name: oscar_starling_mailhog
    image: mailhog/mailhog:latest
    restart: "always"
    ports:
      - 8085:8085
    networks:
      - oscar_starling_network


  oscar_starling_kibana:
    image: docker.elastic.co/kibana/kibana:7.17.23
    container_name: oscar_starling_kibana
    depends_on:
      oscar_starling_elasticsearch:
        condition: service_healthy
    restart: always
    networks:
      - oscar_starling_network
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml
    ports:
      - "5601:5601"

# RéSEAU VIRUEL
networks:
  oscar_starling_network:
    driver: bridge
+14 −0
Original line number Diff line number Diff line
FROM docker.elastic.co/elasticsearch/elasticsearch:7.16.1

# Issue du docker-compose
ARG proxy_environnement
ARG service_oscar_name
ARG service_gearman_name
ARG service_elasticsearch_name

RUN if [ "$proxy_environnement" != "" ]; \
    then echo "Acquire::http::proxy \"$proxy_environnement\";" > /etc/apt/apt.conf.d/proxy; \
    fi

#NO PROXY POUR LES CONTAINERS ENTRE EUX
ENV no_proxy=${service_oscar_name},${service_gearman_name},${service_elasticsearch_name}
Loading