-
Yassine Doghri authored
- update prettier config for markdown file for better readability - fix some formatting issues
Yassine Doghri authored- update prettier config for markdown file for better readability - fix some formatting issues
Setup your development environment
Table of contents
- Introduction
- Prerequisites
- Start docker containers
- Initialize and populate database
- Install/Update app dependencies
- Start hacking
- Going Further
- Developing inside a Container
Introduction
Castopod is a web app based on the php
framework
CodeIgniter 4.
To setup a dev environment, we use Docker. A
docker-compose.yml
and Dockerfile
are included in the project's root folder
to help you kickstart your contribution.
Know that you don't need any prior knowledge of Docker to follow the next steps. However, if you wish to use your own environment, feel free to do so!
Prerequisites
-
Install docker desktop.
-
Clone castopod project by running:
git clone https://code.podlibre.org/podlibre/castopod.git
- Create a
.env
file with the minimum required config to connect the app to the database:
CI_ENVIRONMENT = development
database.default.hostname = mariadb
database.default.database = castopod
database.default.username = podlibre
database.default.password = castopod
NB. You can tweak your environment by setting more environment variables in your custom
.env
file. See theenv
for examples or the CodeIgniter4 User Guide for more info.
- Add the repository you've cloned to docker desktop's
Settings
>Resources
>File Sharing
. - Install castopod's php dependencies
The project's php dependencies aren't included in the repository, you have to download them using the composer service defined in
docker-compose.yml
docker-compose run --rm composer install --ignore-platform-reqs
- Install castopod's js dependencies
The project's js dependencies aren't included in the repository, you have to download them using the node service defined in
docker-compose.yml
docker-compose run --rm node npm install
- Build assets: javascript, styles, icons and svg images
To generate public assets, you must run the following commands.
docker-compose run --rm node npm run build:js
docker-compose run --rm node npm run build:css
docker-compose run --rm node npm run build:icons
docker-compose run --rm node npm run build:svg
Start docker containers
Go to project's root folder and run:
# starts all services declared in docker-compose.yml file
# -d option starts the containers in the background
docker-compose up -d
# See all running processes (you should see 3 processes running)
docker ps
# Alternatively, you can check all processes (you should see composer with an Exited status)
docker ps -a
The
docker-compose up -d
command will boot 3 containers in the background:
castopod_app
: a php based container with codeigniter requirements installedcastopod_mariadb
: a mariadb server for persistent datacastopod_phpmyadmin
: a phpmyadmin server to visualize the mariadb databaseNB.
./mariadb
,./phpmyadmin
folders will be mounted in the project's root directory to persist data and logs.
Initialize and populate database
- Build the database with the migrate command:
# loads the database schema during first migration
docker-compose run --rm app php spark migrate -all
In case you need to roll back, use this command:
# rolls back database schema loading (deletes all tables and their content)
docker-compose run --rm app php spark migrate:rollback
- Populate the database with the required data:
# Populates all required data
docker-compose run --rm app php spark db:seed AppSeeder
You may also add only data you chose:
# Populates all categories
docker-compose run --rm app php spark db:seed CategorySeeder
# Populates all Languages
docker-compose run --rm app php spark db:seed LanguageSeeder
# Populates all podcasts platforms
docker-compose run --rm app php spark db:seed PlatformSeeder
# Populates all Authentication data (roles definition…)
docker-compose run --rm app php spark db:seed AuthSeeder
# Populates test data (login: admin / password: AGUehL3P)
docker-compose run --rm app php spark db:seed TestSeeder
- (optionnal) Populate the database with test data:
docker-compose run --rm app php spark db:seed TestSeeder
This will add an active superadmin user with the following credentials:
- username: admin
- password: AGUehL3P