The dev.script tells Suga how to run your service locally:
Copy
services: api: subtype: # your choice, from target platform dev: script: npm run dev # Node.js worker: subtype: # your choice, from target platform dev: script: python main.py # Python processor: subtype: # your choice, from target platform dev: script: go run main.go # Go
During suga dev, this script runs and can automatically restart on code changes.
In order to establish HTTP routes/requests Suga will automatically inject a PORT env var into each of your services, indicating which port it should start on.
index.ts
Copy
const port = process.env.PORT || 8000;app.listen(port, () => { console.log(`Server running on port ${port}`);});
The working_directory property sets the base directory for the service. All other paths in the service configuration are resolved relative to this directory:
Service with working directory
Copy
services: api: subtype: # your choice, from target platform working_directory: ./api dev: script: npm run dev # Runs from ./api directory container: docker: dockerfile: Dockerfile # Resolves to ./api/Dockerfile context: . # Resolves to ./api
If not specified, the project root (where suga.yaml is located) is used as the working directory.
Services interact with resources like buckets using generated Suga client libraries. For databases, services receive connection strings via environment variables.