Skip to content

Fullstack App

Building on the Hello World basics, this tutorial explores a more realistic project with two components and introduces key EMB features.

  • Multiple components - API backend + web frontend
  • Environment variables - Using .env files and variable expansion
  • Tasks - Running scripts at project and component levels
  • Docker Compose - Managing multi-service applications

We’ll use examples/fullstack-app:

fullstack-app/
├── .emb.yml # Project configuration
├── .env # Environment variables
├── docker-compose.yml # Service definitions
├── api/ # Backend API
│ ├── Dockerfile
│ ├── Embfile.yml # Component-specific config
│ ├── package.json
│ └── server.js
└── web/ # Frontend
├── Dockerfile
├── Embfile.yml
├── index.html
└── nginx.conf

Let’s look at the full configuration:

Terminal window
cat .emb.yml
project:
name: fullstack-app
plugins:
- name: autodocker
- name: dotenv
config:
- .env
- name: embfiles
env:
DOCKER_TAG: ${env:DOCKER_TAG:-latest}
NODE_ENV: ${env:NODE_ENV:-development}
# Project-level tasks demonstrate EMB's task system at the monorepo level.
# These tasks apply to the entire project, not individual components.
tasks:
# Showcases: task variables with environment fallback
# The 'vars' block defines variables available in the script.
# Variables can reference environment variables with defaults: ${env:VAR:-default}
setup:
description: Set up the development environment
vars:
ENV: ${env:NODE_ENV:-development}
script: |
echo "Setting up $ENV environment"
# Showcases: simple task with description
# This task will be used as a prerequisite for 'build'
deps:
description: Install project dependencies
script: |
echo "Installing dependencies..."
echo "deps installed" > /tmp/fullstack-tasks.txt
# Showcases: task prerequisites (pre)
# The 'pre' array lists tasks that must run before this one.
# EMB automatically runs 'deps' before 'build' when you run 'emb run build'
build:
description: Build the entire project
pre: ['deps']
script: |
echo "Building project..."
grep 'deps' /tmp/fullstack-tasks.txt || (echo "Dependencies not installed" && exit 1)

This configuration introduces several new concepts we’ll explore in the following pages.

  1. Project Structure - Multi-component setup with Embfiles
  2. Environment Variables - Using dotenv and variable expansion
  3. Tasks - Defining and running tasks
  4. Docker Compose - Managing services
  5. Building Images - Building and tagging images

You should have completed the Hello World tutorial first.