Getting started
Prerequisites
- Node.js v18.16.0+
- Docker v20.10.17+ or a Kubernetes cluster.
To build a CYK server, the create-cyk program generates either a docker-compose.yml file for Docker Compose or resource files for a Kubernetes cluster.
The Kubernetes cluster can be a cloud service or included in Docker Desktop or Minikube...
The cyk command includes the start and stop subcommands to start and stop the CYK server.
A new project can also be attached to an existing CYK server
Create a new project
- Step 1: Choose project name
At first, go to the place where you want to create a new folder, then :
npx create-cyk@latest
will display :
npx: installed 38 in 11.348s
CykLang - A Full Stack Programming Language
? Project name: › cyk-project
The folder created will have the same name as the project.
- Step 2: Build local Cyk servers with docker
Once you have entered a project name or accepted the default one, indicate if you want to configure a new Cyk server or you want to connect to an existing one.
✔ Project name: … cyk-project
? Cyk Servers : › - Use arrow-keys. Return to submit.
❯ build local Cyk servers with docker
build Cyk server with kubernetes resources
connect to existing Cyk servers
As this is our first Cyk project, accept the default option, which will create two docker containers. One for the Postgresql database, and the other one for the NodeJS server.
- Step 3: Configure the Postgresql Database Server
✔ Postgresql Port: … 5432
✔ Postgresql Admin Login: … postgres
✔ Postgresql Admin Password: … postgres
The Postgresql container server is built from the official image of Postgresql. Even if most of the needs are covered by provided cyk CLI, feel free to connect to the database server with a tool of your choice (psql, pgadmin ...)
- Step 4: Configure the NodeJS Server
✔ Node Server Port: … 3000
✔ Cyk Admin User: … cyk
✔ Cyk Admin Password: … cyk
✔ Cyk Admin Email: …
The container server is built from this public docker image
- Step 5: Build and start servers
Once you have configured the NodeJS server, the utility will automatically:
- write configuration files : package.json, .env, docker-compose.yml
- install locally the cyk command
The console output will be:
Scaffolding project in /private/tmp/cyk-project...
npm install @cyklang/cli@latest ...
added 108 packages, and audited 109 packages in 18s
38 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
* npm install @cyklang/cli@latest
Done. Now run:
cd cyk-project
npx cyk start # will do: docker compose up
- Step 6: Start the server
Go to the project folder and start the server using the cyk command.
cd cyk-project
npx cyk start
The output depends on the chosen orchestrator, whether it's Docker Compose or Kubernetes.
In the case of Kubernetes, the command performs "port-forwarding" between the computer and the specified ports to the Kubernetes cluster services.
The command npx cyk stop stops the cyk server.
- Step 7: Test the newly created server
With your favourite browser, open a page to your new NodeJS server :
http://localhost:3000 (replace 3000 with the port number supplied in Step 4 )
You should see:
