Commit 2f86b618 authored by Julien Fastré's avatar Julien Fastré

improve install procedure

parent 45bbb8bf
......@@ -28,3 +28,4 @@ app/DoctrineMigrations/*
/node_modules/*
.yarncache/*
/web/build
.pgadmin4/*
FROM node:9 AS asset_compilation
WORKDIR /app
COPY . /app
RUN yarn install
RUN yarn run encore production
FROM php:7.2-fpm
MAINTAINER Julien Fastré <julien.fastre@champs-libres.coop>
......@@ -73,7 +62,7 @@ COPY ./web /var/www/app/web/.
COPY ./composer.* /var/www/app/
# import the manifest.json file
COPY --from=asset_compilation /app/web/build/manifest.json /var/www/app/web/build/manifest.json
COPY ./web/build/manifest.json /var/www/app/web/build/manifest.json
ADD ./entrypoint.sh /.
......
THIS_FILE := $(lastword $(MAKEFILE_LIST))
PWD:=$(shell echo ${PWD})
UID:=$(shell id -u)
GID:=$(shell id -g)
DOCKERNODE_CMD=docker run --rm --user ${UID}:${GID} -v ${PWD}:/app --workdir /app -e YARN_CACHE_FOLDER=/app/.yarncache node:9
build-assets:
$(DOCKERNODE_CMD) yarn install
$(DOCKERNODE_CMD) yarn run encore production
init:
docker run --rm -e INSTALL_ID=$(UID) -e INSTALL_GID=$(GID) -e COMPOSER_HOME=/var/www/app/.composer --volume $(PWD):/var/www/app --workdir /var/www/app php:7.2-cli /bin/bash ./docker/install.dev.sh
@$(MAKE) -f $(THIS_FILE) build-assets
......@@ -5,8 +5,10 @@ The Chill project is a fork of [symfony/symfony-standard]
(https://github.com/symfony/symfony-standard). This project has adapted the composer.json
file to adapt to chill installation.
## Requirements
This project use [docker](https://docker.com) to be run. As a developer, use [docker-compose](https://docs.docker.com/compose/overview/) to bootstrap a dev environment in a glance.
- This project use [docker](https://docker.com) to be run. As a developer, use [docker-compose](https://docs.docker.com/compose/overview/) to bootstrap a dev environment in a glance. You do not need any other dependencies ;
- Make is used to automate scripts.
## As a developer
......@@ -16,17 +18,21 @@ As a developer, the code will stay on your computer and will be executed in dock
### Prepare your variables
Have a look at the variable in [`env.dist`](env.dist) and check if you need to adapt them. If they do not adapt with your need, or if some are missing:
Have a look at the variable in [`env.dist`](env.dist) and in [`app/config/parameters.yml.dist`](app/config/parameters.yml.dist) and check if you need to adapt them. If they do not adapt with your need, or if some are missing:
1. copy the file as `.env`: `cp env.dist .env`
2. replace the variable inside `.env`
3. copy the file `parameters.yml.dist`: `cp app/config/parameters.yml.dist app/config/parameters`
4. replace eventually the variable inside this file
**Note**: If you intend to use the bundle `Chill-Doc-Store`, you will need to configure and install an openstack object storage container with temporary url middleware. You will have to configure [secret keys](https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#secret-keys).
### Run the bootstrap script
This script must be run inside the container, without the default `entrypoint`:
This script can be run using `make`
```bash
docker-compose run --user <uid> --entrypoint /usr/bin/env php /bin/bash docker/install.dev.sh
make init
```
This script will :
......@@ -40,7 +46,7 @@ This script will :
run those commands:
```
bash docker-node yarn run encore prod
make build-assets
```
### Start the project
......@@ -49,9 +55,24 @@ bash docker-node yarn run encore prod
docker-compose up
```
**Note** after the first run, and after each upgrade, you must execute migrations. See the dedicated _how-to_.
**On the first run** (and after each upgrade), you must execute database migrations:
```
docker-compose exec --user <uid> php app/console doctrine:migrations:migrate
```
Chill will be available at http://localhost:8001. Currently, there isn't any user or data. To add fixtures, run
```
docker-compose exec --user <uid> php app/console doctrine:fixtures:load
```
There are several users available:
- `center a_social`
- `center b_social`
Chill will be available at http://localhost:8001 .
The password is always `password`.
Now, read the how-tos.
......@@ -144,6 +165,7 @@ Executing `bash docker-node.sh` will open a terminal in a node:9 container, with
## Running in production
TODO
## Design principles
......
This diff is collapsed.
......@@ -6,7 +6,8 @@ services:
context: .
args:
UID: ${PHP_FPM_USER:-1000}
image: chill/activity-docs-person-report-task-php:${VERSION:-latest}
# uncomment and set your own image if needed
# image: chill/activity-docs-person-report-task-php:${VERSION:-latest}
volumes:
- .:/var/www/app
environment:
......
#!/bin/sh
# stop script if a step fails
set -e
# create a temporary user
groupadd -g ${INSTALL_GID} installgroup
useradd -u ${INSTALL_ID} -g ${INSTALL_GID} installuser
echo 'install composer'
EXPECTED_SIGNATURE=$(curl -o /dev/stdout --silent https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
su installuser -c "php -r \"copy('https://getcomposer.org/installer', 'composer-setup.php');\""
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
......@@ -13,7 +20,7 @@ then
exit 1
fi
php composer-setup.php
su installuser -c "php composer-setup.php"
rm composer-setup.php
echo ''
......@@ -22,7 +29,26 @@ echo ''
echo 'install deps'
echo ''
php composer.phar install
apt update && apt -y --no-install-recommends install wget gnupg \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt update \
&& apt -y --no-install-recommends install \
libicu-dev \
g++ \
libzip-dev \
libfreetype6-dev \
postgresql-server-dev-10 \
libpng-dev \
libjpeg62-turbo-dev \
git \
zip \
unzip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install intl pdo_pgsql mbstring zip bcmath sockets exif
su installuser -c "php -d memory_limit=2G composer.phar install --no-scripts --ignore-platform-reqs"
echo ''
echo 'deps installed sucessfully'
......
FROM node:9 AS asset_compilation
WORKDIR /app
COPY . /app
RUN yarn install
RUN yarn run encore production
FROM nginx
COPY --from=asset_compilation /app/web /var/www/app/web
COPY ./web/bundles /var/www/app/web/bundles
COPY ./web /var/www/app/web
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment