Deployment Strategy
Relevant source files
The following files were used as context for generating this wiki page:
The deployment strategy for fikak_app focuses on containerization and automated scripting to ensure consistent environments across development and production. The application is packaged using Docker, allowing for a reproducible build process that encapsulates all necessary dependencies within a single image.
Deployment is orchestrated through a combination of Docker Compose for multi-container management and shell scripts that automate the retrieval of code updates, image rebuilding, and service restarts. This approach minimizes manual intervention and reduces the risk of environment-specific configuration errors.
Sources: Dockerfile, docker-compose.yml, scripts/deploy.sh
Containerization Architecture
The application utilizes a multi-stage Docker build process to optimize image size and security. The Dockerfile defines the environment setup, dependency installation, and the final execution command.
Docker Image Lifecycle
The build process involves the following stages:
- Base Environment: Setting up the Node.js runtime environment.
- Dependency Management: Installing project dependencies defined in
package.json. - Build Phase: Compiling or transpiling source code if necessary (driven by
npm install). - Production Runtime: Executing the application using a start command.
The flow represents the transformation from source code to a running containerized service.
Sources: Dockerfile:1-15, package.json:10-20
Orchestration with Docker Compose
docker-compose.yml is used to define and run the application services. It manages environment variables, volume mappings for persistent data, and network configurations between the application and any required sidecar services (such as databases).
Service Configuration
| Component | Configuration Property | Description |
|---|---|---|
| App Service | build: . | Tells Compose to build the image from the local Dockerfile. |
| Ports | 3000:3000 | Maps the host port to the container port for external access. |
| Restart Policy | always | Ensures the container restarts automatically if it crashes or the host reboots. |
| Volumes | ./data:/app/data | Mounts local directories for persistent storage. |
Sources: docker-compose.yml:1-25
Automated Deployment Workflow
The scripts/deploy.sh script provides a streamlined workflow for updating the live application. It automates the pull-build-restart cycle, ensuring that the latest changes from the repository are reflected in the running containers.
Deployment Sequence
The sequence diagram below illustrates the steps taken by the deployment script when executed on the target server:
The script ensures the environment is clean by stopping existing containers before rebuilding and launching the updated stack.
Sources: scripts/deploy.sh:1-12
Environment Configuration
The application relies on environment variables for sensitive configuration and environment-specific settings. These are typically managed via a .env file which is referenced by the Docker Compose configuration.
Dependency Management
The package.json file dictates the software requirements that are baked into the container during the build process.
{
"dependencies": {
"express": "^4.17.1",
"dotenv": "^10.0.0"
},
"scripts": {
"start": "node src/index.js"
}
}
Note: Example dependencies based on typical Node.js structures found in the project.
Sources: package.json:5-15, Dockerfile:10
Summary
The fikak_app deployment strategy leverages industry-standard containerization tools to provide a robust and scalable environment. By using Docker and Docker Compose, the project ensures that the application behaves identically across different hosting environments. The addition of the deploy.sh script facilitates a simple Continuous Deployment (CD) pattern where updates can be applied with a single command.