Development
This article describes several items that are needed for development. The Baseline application consists of a backend as well as a frontend part and requires other services, such as Nexus.
Preparation - Access to external services
The backend relies on other services - such as Nexus - which have to be started and configured.
These services can be started with:
docker-compose up -d
Nexus is now accessible under localhost and the port specified in the docker-compose file, e.g. under http://localhost:8081/.
The password for a first nexus admin
login is saved in a file inside the docker container and can be read out with the following command:
docker exec -it baseline_nexus_1 cat /nexus-data/admin.password
In Nexus a raw repository with a file providing the project-list has to be created.
The baseline.yaml should contain the configuration of the repository and the admin credentials.
Various options for the development
There are several options for development of the baseline dogus, as described below.
Separate backend and frontend
To be more flexible during development the frontend can be delivered independently of the backend.
Backend
Execute one of the following commands in the root directory of this repository to start the backend (the API)
Backend server (provides API):
go run .
or alternatively with version set:
go run -ldflags="-X 'main.Version=1.0.0'" .
Frontend
The UI is located in the sub-directory 'ui'.
Execute the following commands starting from the root directory of this repository to start the frontend (the UI):
cd ui
yarn install
yarn run start
The URL for accessing the frontend is displayed in the terminal after startup.
Close to production - Frontend delivered from the backend
For a close to production setup, the frontend should be build/packed and then be delivered from the backend:
Execute the following commands starting from the root directory of this repository to build/pack the frontend:
cd ui
yarn install
yarn build
After that, the backend delivers the frontend. To do this, run the following command in the root directory of this repository:
go run .
The frontend can now be accessed with http://localhost:8080 .
Mocking API - UI only without backend
Alternatively, the API can be mocked so that the backend does not have to be started. The data is read from a json file.
Execute the following commands starting from the root directory of this repository to start API-Mock (backend-mock):
cd ui/api-mock
npm install -g json-server
json-server --watch db.json --p 8080 --routes routes.json
The db.json contains the API data and can be extended on demand.
To start the frontend, see section Frontend