Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# symfony/framework-bundle
APP_ENV=dev
URL=local.appbuild.com
DB_URL=mysql://appbuild_usr:appbuild_pwd@local.appbuild-db.com/appbuild_db
SYMFONY_SECRET=ThisTokenIsNotSoSecretChangeIt
# Supported values are 'en' and 'fr'
DEFAULT_LOCALE=en
# Timezone to use when displaying dates (either on backoffice or API)
TIMEZONE=UTC
# Symfony session path (set this to '/tmp/sessions' for example if you encounter some issues in dev environment)
SESSION_SAVE_PATH=%kernel.project_dir%/var/sessions/%kernel.environment%
# Path to the directory where builds file will be stored
BUILDS_APPLICATION_DIR=%kernel.project_dir%/var/build_files
# symfony/swiftmailer-bundle
MAILER_TRANSPORT=smtp
MAILER_HOST=127.0.0.1
MAILER_USER=null
MAILER_PASSWORD=null
# webpack-dev-server (to watch assets modification in development environment)
WEBPACK_DEV_SERVER_BASE_URL=http://local.appbuild.com:8080
# JWT parameters for API authentication
JWT_PRIVATE_KEY_PATH=%kernel.project_dir%/var/jwt/private.pem
JWT_PUBLIC_KEY_PATH=%kernel.project_dir%/var/jwt/public.pem
JWT_KEY_PASS_PHRASE=Appbuild
# Approximately one year
JWT_TOKEN_TTL=31536000
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
/.idea/
/*.log

# ansible-vagrant
/.vagrant/
/ansible/roles/
/ansible/vars.local.yml
/ansible/vagrant-parameters.yml
/ansible/*.retry

# vendor, cache, logs, parameters, binaries
/app/config/parameters.yml
/var/*
!/var/cache/
/var/cache/*
Expand Down Expand Up @@ -39,3 +31,7 @@

# deploy
/deploy/

# docker volume
/.data/
.env
27 changes: 24 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
language: php

php:
- 5.6.19
- 7.0
- 7.1

services:
- mysql

env:
- APP_ENV=dev
URL=local.appbuild.com
DB_URL=mysql://root@127.0.0.1/appbuild_db
SYMFONY_SECRET=ThisTokenIsNotSoSecretChangeIt
DEFAULT_LOCALE=en
TIMEZONE=UTC
SESSION_SAVE_PATH=%kernel.project_dir%/var/sessions/%kernel.environment%
BUILDS_APPLICATION_DIR=%kernel.project_dir%/var/build_files
MAILER_TRANSPORT=smtp
MAILER_HOST=127.0.0.1
MAILER_USER=null
MAILER_PASSWORD=null
WEBPACK_DEV_SERVER_BASE_URL=http://local.appbuild.com:8080
JWT_PRIVATE_KEY_PATH=%kernel.project_dir%/var/jwt/private.pem
JWT_PUBLIC_KEY_PATH=%kernel.project_dir%/var/jwt/public.pem
JWT_KEY_PASS_PHRASE=Appbuild
JWT_TOKEN_TTL=31536000

before_script:
- cp .env.dist .env
- nvm install "$(jq -r '.engines.node' package.json)"
- make install-bin-dev install-bin-prod install-composer install-npm db-build assets-build
- make install-bin-dev install-bin-prod install-composer install-npm db-build-test assets-build

script:
- npm run lint
Expand Down
68 changes: 37 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,52 @@

## Development

This project uses [LinkValue/majora-ansible-vagrant v2.2.0](https://github.com/LinkValue/majora-ansible-vagrant/tree/v2.2.0) as its development environment,
so please head to this link and fulfill the **Requirements** section for your OS before anything else.
Requirements
- Docker
- Docker compose

### Installation

#### 1. Clone project
```shell
git clone git@github.com:LinkValue/Appbuild.git
```shell
# Add this line to the host file /etc/hosts
127.0.0.1 local.appbuild.com

# copy sources from GitHub
git clone https://github.com/LinkValue/Appbuild.git
cd Appbuild
```

#### 2. Virtual machine provisioning
```shell
make provision
```
# Start project
docker-compose up -d

Note: If it unluckily fails at some point, don't hesitate to re-run this command several times.
# Setup api
# Get a bash shell in the nginx container
docker exec -it appbuild_nginx bash
cd /app

#### 3. Install project
```shell
# connect to the VM
make ssh
# install the project for development (you'll have to press "Enter" several times to configure the project with default parameters)
make install
```
# Install JWT
mkdir -p var/jwt
test -f var/jwt/private.pem || openssl genrsa -out var/jwt/private.pem -passout pass:Appbuild -aes256 4096
test -f var/jwt/public.pem || openssl rsa -in var/jwt/private.pem -passin pass:Appbuild -pubout -out var/jwt/public.pem

#### 4. Enjoy
# Setup db
# use php-fpm container
docker exec -it appbuild_php_fpm php bin/console doctrine:database:create --if-not-exists
docker exec -it appbuild_php_fpm php bin/console doctrine:migrations:migrate -n
docker exec -it appbuild_php_fpm php bin/console doctrine:fixtures:load -n --fixtures=src/UserBundle

You should see your application up and running at http://local.appbuild.com/app_dev.php/
# Reset db
# use php-fpm conatainer
docker exec -it appbuild_php_fpm php bin/console doctrine:database:drop --force --if-exists
docker exec -it appbuild_php_fpm php bin/console doctrine:database:create

# You can also watch asset modifications
docker logs -f appbuild_node

# Start webpack server if is not started yet, use node container
docker exec -it appbuild_node npm start
```

You should see your application up and running at http://local.appbuild.com

Try to login using one of the following credentials:
```
Expand All @@ -40,17 +57,6 @@ admin@admin.fr => admin
user@user.fr => user
```

### Frontend development

Front assets (css/js/images) are handled by [Webpack](https://webpack.js.org/).

When you're in production environment (i.e. `http://local.appbuild.com/...`), the project will use the assets found in `web/assets`, it means that you'll have to run `make assets-build` each time you edit an asset file to see the modification in your browser (after refreshing it manually).

When you're in development environment (i.e. `http://local.appbuild.com/app_dev.php/...`), you can also watch asset modifications to benefit from the hot reloading feature of webpack-dev-server, by typing the following command:
```shell
make assets-watch
```

### Common tasks
```shell
# rebuild the whole database with clean fixtures
Expand Down
38 changes: 7 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
.PHONY: provision start stop ssh destroy rebuild clean install update clean

#
# Main targets
#
provision: vm-provision
start: vm-up
stop: vm-halt
ssh: vm-ssh
destroy: vm-destroy
rebuild: vm-rebuild

#
# VM
#
vm-ssh:
vagrant ssh

vm-up:
vagrant up

vm-halt:
vagrant halt

vm-provision:
vagrant up --no-provision
vagrant provision

vm-destroy:
vagrant destroy

vm-rebuild: vm-destroy vm-provision

# Clean
clean:
php bin/console cache:clear --no-warmup
Expand Down Expand Up @@ -71,6 +40,13 @@ db-build:
php bin/console doctrine:fixtures:load -n --fixtures=src/UserBundle
php bin/console hautelook_alice:doctrine:fixtures:load -n --append

# Database
db-build-test:
php bin/console doctrine:database:create
php bin/console doctrine:schema:update --force
php bin/console doctrine:fixtures:load -n --fixtures=src/UserBundle
php bin/console hautelook_alice:doctrine:fixtures:load -n --append --bundle=AppbuildApplicationBundle

db-trash:
php bin/console doctrine:database:drop --force --if-exists
php bin/console doctrine:database:create
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: $(composer config bin-dir)/heroku-php-nginx -C nginx_app.conf web/
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Host your iOS/Android apps for an easy installation on allowed user devices.

## Installation

Appbuild is a "simple" [Symfony 3.3](http://symfony.com/doc/3.3/index.html) application.
Appbuild is a "simple" [Symfony 3.4](http://symfony.com/doc/3.4/index.html) application.

### Server requirements

Expand All @@ -42,21 +42,17 @@ cd /var/www
git clone https://github.com/LinkValue/Appbuild.git
cd Appbuild

# configure application
# by copying "app/config/parameters.yml.dist" to "app/config/parameters.yml"
# and editing "app/config/parameters.yml" to fit your context

# install dependencies and assets
# a Makefile (see https://www.gnu.org/software/make) is present to build the project from sources,
# so just run the following command:
make prod-deploy
```

Notice that you'll probably also need to setup correct file permissions on the `var` directory, see [this guide](http://symfony.com/doc/3.3/setup/file_permissions.html) to know what you can do.
Notice that you'll probably also need to setup correct file permissions on the `var` directory, see [this guide](http://symfony.com/doc/3.4/setup/file_permissions.html) to know what you can do.

### HTTP server configuration

The HTTP server configuration looks like [any other Symfony application](https://symfony.com/doc/3.3/setup/web_server_configuration.html), just keep in mind the following points:
The HTTP server configuration looks like [any other Symfony application](https://symfony.com/doc/3.4/setup/web_server_configuration.html), just keep in mind the following points:

- `https` is required to download iOS applications (if you don't want to pay for a SSL certificate, we suggest to use [Certbot](https://certbot.eff.org) which is a [Let's Encrypt](https://letsencrypt.org) wrapper to generate official SSL certificates)
- you may want to increase the max upload size (either in PHP and HTTP server configuration) to be able to upload large build files
Expand Down
Loading