CI/CD Automation Scripts
Overview
The project implements a CI/CD automation process that facilitates building, testing, and preparing the application for deployment. This documentation details the scripts and configurations that contribute to the CI/CD pipeline.
CI/CD Configuration
The CI/CD process utilizes a GitHub Actions workflow defined in the .github/workflows/build.yml
file. However, the specific contents of build.yml
are not provided, indicating that it might not be fully set up. Next steps are suggested to create or enhance this configuration.
Key Build Scripts and Files
Dockerfile
The
Dockerfile
defines multiple stages for building the application, including testing and packaging. Below are the key sections relevant to CI/CD automation:# Install the base requirements for the app. FROM --platform=$BUILDPLATFORM python:alpine AS base WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt FROM --platform=$BUILDPLATFORM node:18-alpine AS app-base WORKDIR /app COPY app/package.json app/yarn.lock ./ COPY app/spec ./spec COPY app/src ./src # Run tests to validate app FROM app-base AS test RUN yarn install RUN yarn test
In this snippet, the
test
stage verifies that the application passes all tests defined in theapp/spec
directory. The use of multi-stage builds ensures that only the necessary artifacts are retained in the final image.docker-compose.yml
The
docker-compose.yml
file sets up a development environment which is useful for local testing before deploying code changes:version: "3.7" services: docs: build: context: . dockerfile: Dockerfile target: dev ports: - 8000:8000 volumes: - ./:/app
This configuration enables rapid development and testing, allowing developers to view changes live on port 8000 and ensuring local updates are reflected in the container.
build.sh
The
build.sh
script, though not detailed here, is typically used in CI environments to automate the process of building images. Its inclusion suggests a potential script that could tie into the CI/CD pipeline.
Testing
The testing strategy is embedded within the Docker build as shown in the Dockerfile
. The following commands execute the tests:
# Run tests to validate app
FROM app-base AS test
RUN yarn install
RUN yarn test
This ensures each commit or pull request can trigger tests automatically, integrating quality checks into the workflow.
Next Steps for CI/CD Enhancement
If the .github/workflows/build.yml
file is not yet fully configured or available, consider the following actions:
Create the CI Workflow: Draft a GitHub Actions workflow that specifies the triggers (e.g., on push or pull request) and runs the build process, tests, and any linting or other quality checks.
Example of a basic structure might look like:
name: CI on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Build run: docker-compose build - name: Test run: docker-compose run test
Integrate Notifications: Add steps to notify the team with the result of the CI process using GitHub Actions notifications or integrations with other systems.
Deploy Automation: Investigate further steps to automate deployment using GitHub Actions or other CI/CD tools to push images to a container registry and deploy to production.
Conclusion
The existing scripts and configurations provide a solid foundation for implementing CI/CD. Enhancements to the CI workflow would ensure robust automation, allowing for efficient and error-free code integration and deployment processes.
Source: Dockerfile and docker-compose.yml in the project structure.