Skip to content

Commit

Permalink
WIP add working dev docker-compose for all architecture
Browse files Browse the repository at this point in the history
didn't test maildev for now.
  • Loading branch information
oiseauroch committed Dec 26, 2023
1 parent 880cb60 commit 825d729
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 81 deletions.
5 changes: 0 additions & 5 deletions cache/README.md

This file was deleted.

65 changes: 51 additions & 14 deletions docker/README.md
Expand Up @@ -4,25 +4,62 @@

From within `docker` folder

```bash
docker compose build
- create a file `.env` with the following value : 


```
export UID="YOUR_USER_ID" # can be found with id -u
export GID="YOUR_USER_GID" # can be found with id -g
```
- copy the file `yeswiki.secret.example` to `yeswiki.secret`
- build the container
```
docker compose build
```
- launch image
```
docker compose up -d
```

It should take some time for the first launch, it will perform `compose install` and `yarn install`.
then yeswiki will be accessible at `localhost:8085`, phpmyadmin at `localohost:8086` and mailcatcher at `localhost:1080`

## Launch image
Once on the install page, use the following values :

- `docker compose up -d`
- yeswiki should be accessible at `localhost:8085`
- **Mysql server host** : yeswiki-db
- **MYSQL database name** : yeswiki (can be fond in yeswiki.secret)
- **MYSQL username** : yeswiki (can be fond in yeswiki.secret)
- **MYSQL password** : password (can be fond in yeswiki.secret)

## Dev version
> [!]tips
> if you have a previous developpement installation you may need to change value accordingly in the wakka.config.php
- allow www-data to right local directory
This version should map the local repository to your docker container.
- `docker compose -f docker-compose-dev.yml up`
## reinitialize yeswiki repo from dev

## Remove all docker images and volumes
docker create and populates the following folders files :

```bash
docker compose stop
docker compose rm
docker volume rm yeswiki yeswiki-db
- vendor (for php dependencies)
- node_modules (for yarn dependencies)
- wakka.config.php
- cache
- tools/bazar/vendor/

## Remove database

- remove containers
```
docker compose down
```
- remove docker volume
```
docker volume rm yeswiki-db
```

## updating php or yarn dependency

```
docker compose exec yeswiki-app bash
composer install
yarn install
```
Expand Up @@ -3,6 +3,8 @@ version: "3.7"
volumes:
yeswiki-db:
name: yeswiki-db
yeswiki:
name: yeswiki

networks:
yeswiki:
Expand Down
93 changes: 58 additions & 35 deletions docker/docker-compose.yml
Expand Up @@ -3,45 +3,68 @@ version: "3.7"
volumes:
yeswiki-db:
name: yeswiki-db
yeswiki:
name: yeswiki

networks:
yeswiki:

services:
yeswiki-app:
build:
context: ..
dockerfile: ./docker/dockerfile
container_name: yeswiki
volumes:
- yeswiki:/var/www/html
depends_on:
- yeswiki-db
env_file: ./yeswiki.secrets
networks:
- yeswiki
yeswiki-app:
build:
context: ..
dockerfile: ./docker/dockerfile
args:
UID: "${UID:-1000}"
GID: "${UIS:-1000}"
container_name: yeswiki
volumes:
- ..:/var/www/html
depends_on:
- yeswiki-db
env_file: ./yeswiki.secrets
user: "${UID}:${UID}"
command: /var/www/html/docker/entrypoint.sh
networks:
- yeswiki

yeswiki-db:
image: mysql:latest
container_name: yeswiki-db
volumes:
- yeswiki-db:/var/lib/mysql
env_file: ./yeswiki.secrets
networks:
- yeswiki
restart: unless-stopped
yeswiki-db:
image: mysql:latest
container_name: yeswiki-db
volumes:
- yeswiki-db:/var/lib/mysql
env_file: ./yeswiki.secrets
networks:
- yeswiki

yeswiki-web:
image: nginx:alpine
container_name: yeswiki-web
volumes:
- ..:/var/www/html:ro
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8085:80"
depends_on:
- yeswiki-app
- myadmin
networks:
- yeswiki

myadmin:
image: phpmyadmin:latest
container_name: myadmin
env_file: ./yeswiki.secrets
environment:
PMA_HOST: yeswiki-db
PMA_PORT: 3306
ports:
- "8086:80"
networks:
- yeswiki

yeswiki-web:
image: nginx:alpine
container_name: yeswiki-web
volumes:
- yeswiki:/var/www/html:ro
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8085:80"
depends_on:
- yeswiki-app
networks:
- yeswiki
mail:
image: maildev/maildev
container_name: mail
ports:
- "1080:1080"
networks:
- yeswiki
44 changes: 19 additions & 25 deletions docker/dockerfile
@@ -1,34 +1,28 @@

# download composer dependencies
FROM composer:2.1.11 AS composer
WORKDIR /var/www/html

ENV COMPOSER_VENDOR_DIR=/php/vendor

RUN --mount=type=bind,source=..,target=.,rw composer install --no-dev --no-scripts --ignore-platform-reqs

# download nodejs dependencies
FROM node:20 AS yarn
WORKDIR /var/www/html

RUN apt-get update && apt-get install -y git

COPY .. .

RUN yarn install


# Yeswiki image
# Yeswiki dev image
FROM php:8.2-fpm

RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev && \
RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev git unzip && \
rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mysqli gd zip

COPY . /var/www/html/
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

ARG UID

ARG GID

RUN groupadd -g "${UID}" yeswiki \
&& useradd --no-log-init --create-home -u "${UID}" -g "${UID}" -g www-data yeswiki

COPY --from=composer /php/vendor /var/www/html/vendor/
COPY --from=yarn /var/www/html/node_modules/ /var/www/html/node_modules/
USER yeswiki

RUN chown -R www-data:www-data /var/www/html/
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash && \
export NVM_DIR="$HOME/.nvm" && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
echo 'export NVM_DIR="/home/yeswiki/.nvm"' >> $HOME/.bashrc && \
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.bashrc && \
nvm install 20 && \
nvm alias default 20 && \
corepack enable
34 changes: 34 additions & 0 deletions docker/dockerfile-prod
@@ -0,0 +1,34 @@

# download composer dependencies
FROM composer:2.1.11 AS composer
WORKDIR /var/www/html

ENV COMPOSER_VENDOR_DIR=/php/vendor

RUN --mount=type=bind,source=..,target=.,rw composer install --no-dev --no-scripts --ignore-platform-reqs

# download nodejs dependencies
FROM node:20 AS yarn
WORKDIR /var/www/html

RUN apt-get update && apt-get install -y git

COPY .. .

RUN yarn install


# Yeswiki image
FROM php:8.2-fpm

RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev && \
rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mysqli gd zip

COPY . /var/www/html/

COPY --from=composer /php/vendor /var/www/html/vendor/
COPY --from=yarn /var/www/html/node_modules/ /var/www/html/node_modules/

RUN chown -R www-data:www-data /var/www/html/
27 changes: 27 additions & 0 deletions docker/dockerfile_test.yml
@@ -0,0 +1,27 @@
# download composer dependencies
FROM composer:2.1.11 AS composer
WORKDIR /var/www/html

COPY .. .

RUN composer install --no-dev --no-scripts --ignore-platform-reqs

# download nodejs dependencies
FROM node:20 AS yarn
WORKDIR /var/www/html

RUN apt-get update && apt-get install -y git

COPY --from=composer /var/www/html /var/www/html

RUN yarn install


# Yeswiki image
FROM php:8.2-fpm

RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev && \
rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mysqli gd zip
COPY --from=yarn --chown=www-data:www-data /var/www/html /var/www/html
8 changes: 8 additions & 0 deletions docker/entrypoint.sh
@@ -0,0 +1,8 @@
#!/bin/bash
cd /var/www/html
composer install
source /home/yeswiki/.nvm/nvm.sh
nvm use 20
corepack enable
yarn install
php-fpm
4 changes: 2 additions & 2 deletions docker/nginx.conf
Expand Up @@ -28,13 +28,11 @@ http {
set_real_ip_from 192.168.0.0/16;
real_ip_header X-Real-IP;

#gzip on;

upstream php-handler {
server yeswiki-app:9000;
}


server {
listen 80;

Expand Down Expand Up @@ -112,4 +110,6 @@ http {
access_log off;
}
}

}

0 comments on commit 825d729

Please sign in to comment.