####Since 1.15.0, our default compose file contains two web server (caddy or nginx). As the consequences, you need to choose which one to use on deployment command
To install/ deploy this service, we support the following method:
- Fully Dockerized for Development
- Fully Dockerized for Deployment and Production
- Use Symfony console
- Fully use native OS services
This method only require you to have Docker Engine installed on the host.
First, clone this repository:
$ git clone [email protected]:dadangnh/iam.git some_dir
$ cd some_dir
Then, create your environment by editing .env
and save as .env.local
or you can use OS's environment variable or use Symfony Secrets. Create your JWT passphrase on the JWT_PASSPHRASE key.
Make sure to adjust the credentials on the environment for the Docker. You can find inside docker-compose.yaml file
Create the docker environment with caddy:
$ docker-compose up -d database redis php caddy
Create the docker environment with nginx:
$ docker-compose up -d database redis php nginx
Generate Private and public key for JWT Token (or you can use your own key and place it to config/jwt folder):
$ docker-compose exec php sh -c '
set -e
apk add openssl
mkdir -p config/jwt
jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')}
echo "$jwt_passphrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
echo "$jwt_passphrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout
setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
'
> docker-compose exec php /bin/sh
You will enter docker shell, then run (line by line, do not paste it as a whole):
set -e
apk add openssl
mkdir -p config/jwt
export jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')}
echo "$jwt_passphrase" | openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096 --pass stdin
echo "$jwt_passphrase" | openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout --passin stdin
setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
exit
$ docker-compose exec php composer install
run the migration:
$ docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
run the following to add dummy data:
$ docker-compose exec php bin/console doctrine:fixtures:load --no-interaction
Now your app are ready to use:
Landing page: https://localhost/
API Endpoint and Docs: https://localhost/api
Admin page: https://localhost/admin
default credentials:
root:toor
admin:admin
upk_pusat:upk_pusat
Unit testing also available with the following command:
$ docker-compose exec php bin/phpunit
This method only require you to have Docker Engine installed on the host.
Copy your project on the server using git clone
, scp
or any other tool that may fit your need.
If you use GitHub, you may want to use a deploy key.
Deploy keys are also supported by GitLab.
Example with Git:
$ git clone [email protected]:dadangnh/iam.git
Go into the directory containing your project (<project-name>
), and start the app in production mode (caddy):
$ SERVER_NAME=your-domain-name.example.com docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d database redis php caddy
Be sure to replace your-domain-name.example.com
by your actual domain name.
Your server is up and running, and a Let's Encrypt HTTPS certificate has been automatically generated for you.
Go to https://your-domain-name.example.com
and enjoy!
Alternatively, if you don't want to expose an HTTPS server but only an HTTP one, run the following command:
$ SERVER_NAME=:80 docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d database redis php caddy
By default, the nginx image run both on http and https protocol, there is no redirection yet, so it can be run with:
$ SERVER_NAME=:80 docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d database redis php nginx
This method only require you to have the following tools:
-
Docker Engine installed on the host.
First, clone this repository:
$ git clone [email protected]:dadangnh/iam.git some_dir
$ cd some_dir
Then, create your environment by editing .env
and save as .env.local
or you can use OS's environment variable or use Symfony Secrets. Create your JWT passphrase on the JWT_PASSPHRASE key.
Make sure to adjust the credentials on the environment for the Docker. You can find inside docker-compose.yaml file
Create the docker environment for the database and redis:
$ docker-compose up -d database redis
$ mkdir -p config/jwt
$ openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
$ openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout
$ symfony composer install
run the migration:
$ docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
run the following to add dummy data:
$ docker-compose exec php bin/console doctrine:fixtures:load --no-interaction
Now your app are ready to use:
Landing page: https://localhost:8080/
API Endpoint and Docs: https://localhost:8080/api
Admin page: https://localhost:8080/admin
default credentials:
root:toor
admin:admin
upk_pusat:upk_pusat
Unit testing also available with the following command:
$ php bin/phpunit
This method only require you to have the following tools:
First, clone this repository:
$ git clone [email protected]:dadangnh/iam.git some_dir
$ cd some_dir
Then, create your environment by editing .env
and save as .env.local
or you can use OS's environment variable or use Symfony Secrets. Create your JWT passphrase on the JWT_PASSPHRASE key.
$ mkdir -p config/jwt
$ openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
$ openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout
$ symfony composer install
run the migration:
$ php bin/console doctrine:migrations:migrate --no-interaction
run the following to add dummy data:
$ php bin/console doctrine:fixtures:load --no-interaction
Now your app are ready to use:
Landing page: https://localhost:8080/
API Endpoint and Docs: https://localhost:8080/api
Admin page: https://localhost:8080/admin
default credentials:
root:toor
admin:admin
upk_pusat:upk_pusat
Unit testing also available with the following command:
$ php bin/phpunit