- Installation
- Running the project
- Deployment
- Troubleshooting
- Useful Postgres commands
- Used commands to init the project (only for reference)
-
Install Docker
-
Install Erlang
-
Install Elixir
-
Start your Postgres container
docker run --name postgres-container -e POSTGRES_PASSWORD=pwd -p 5432:5432 -d postgres:latest
-
If needed, edit Postgre credentials in
config/dev.exs
andconfig/test.exs
-
Install the dependencies
mix deps.get
-
Create and migrate the database
mix ecto.setup
-
Install Node.js
-
Install the dependencies
npm install
-
Start your Postgres container
docker run --name postgres-container -e POSTGRES_PASSWORD=pwd -p 5432:5432 -d postgres:latest
-
In the backend folder, run
mix phx.server
-
In the frontend folder, run
npm run dev
-
Open your browser and go to
http://localhost:80
To deploy the project to the server (frontend, backend and database), simply commit your changes and push them to the main
branch. The project will be automatically deployed to the AWS EC2 using the deployment pipeline.
First, you have to install Android Studio. To build the APK, run the following commands in the frontend folder:
npx npm run build && npx cap copy
npx cap sync --inline
npx cap open android
Then, in Android Studio, build the APK by clicking on Build > Build Bundle(s) / APK(s) > Build APK(s).
The APK will be generated in the frontend\android\app\build\outputs\apk\debug
folder.
- If you encounter an error with some pending migrations, run
mix ecto.reset
. If that doesn't work, delete the project directory, clone it again and run the installation steps.
- Enter Postgres container in CLI mode :
docker exec -it postgres-container bash
psql -h localhost -U postgres
- Connect to the timemanager database
\c timemanager_dev
- List all tables
\dt
- List all columns of a table
\d <table_name>
You can also run SQL queries directly in the Postgres container, e.g. SELECT * FROM users;
-
Start Postgres
docker run --name postgres-container -e POSTGRES_PASSWORD=pwd -p 5432:5432 -d postgres:latest
-
Install Hex
mix local.hex
-
Install Phoenix application generator
mix archive.install hex phx_new
-
Run init command
mix phx.new T-POO-700-NCE_10 --app timemanager --module Timemanager --no-html
-
Create the contexts :
mix phx.gen.json UserContext User users username:string email:string
mix phx.gen.json WorkingTimeContext WorkingTime workingtime start:naive_datetime end:naive_datetime user_id:references:users
mix phx.gen.json ClockContext Clock clocks status:boolean time:naive_datetime user_id:references:users