Diarybunda DOCS
Home
Api Documentations
  • Admin Service
  • Alodokter Service
  • Alodokter User Encrypted Service
  • Artikel Service
  • Auth Service
  • Core Service
  • Community Service
  • Notification Service
  • Survey Service
  • Promo Service FE
Api Reference
  • Admin Service
  • Alodokter Service
  • Alodokter User Encrypted Service
  • Artikel Service
  • Auth Service
  • Core Service
  • Community Service
  • Notification Service
  • Survey Service
Changelog Releases
  • Admin Service
  • Alodokter Service
  • Alodokter User Encrypted Service
  • Artikel Service
  • Auth Service
  • Core Service
  • Community Service
  • Notification Service
  • Survey Service
About
Home
Api Documentations
  • Admin Service
  • Alodokter Service
  • Alodokter User Encrypted Service
  • Artikel Service
  • Auth Service
  • Core Service
  • Community Service
  • Notification Service
  • Survey Service
  • Promo Service FE
Api Reference
  • Admin Service
  • Alodokter Service
  • Alodokter User Encrypted Service
  • Artikel Service
  • Auth Service
  • Core Service
  • Community Service
  • Notification Service
  • Survey Service
Changelog Releases
  • Admin Service
  • Alodokter Service
  • Alodokter User Encrypted Service
  • Artikel Service
  • Auth Service
  • Core Service
  • Community Service
  • Notification Service
  • Survey Service
About
    • Diarybunda Documentation
    • Project Deployment
    • Required Dependencies
    • Help Center
      • About
      • FAQ

    Project Deployment

    How To deployment new project to staging server.#

    Step 1 . Create Docker file#

    Create docker file on project.
    image.png
    Example dockerfile springboot project :
    Dockerfile.yml

    Step 2. Create github workflow#

    The GitHub workflow provided in the YAML format is used for publishing a Docker image to GitHub Packages. GitHub Packages is a package hosting service provided by GitHub, and it allows you to store and manage container images, npm packages, Maven packages, and other types of packages.
    create file docker-iamge.yml on directory /.github/workflows on project
    image.png
    Example fithub workflow docker-image.yml file :
    Here's a breakdown of what the workflow does:
    1.
    Trigger Conditions:
    The workflow will be triggered under the following conditions:
    On every push to the "master" or "development" branches.
    On every push to a tag that matches the pattern "v1.**".
    On every pull request targeting the "development" branch.
    2.
    Jobs:
    The workflow contains a single job named "push_to_registry".
    3.
    Runs on:
    The job is set to run on an "ubuntu-latest" runner, which means it will execute on a GitHub-hosted virtual machine running the latest version of Ubuntu Linux.
    4.
    Steps:
    The job contains several steps to be executed in sequence:
    a. Check out the repo: This step checks out the repository code so that subsequent steps can access it.
    b. Check Dockerfile: It lists the files in the repository (using "ls" command) and prints the content of the Dockerfile (using "cat Dockerfile"). This step is for debugging purposes and can be removed if not needed.
    c. Docker meta: This step uses the "docker/metadata-action" GitHub Action to generate metadata about the Docker image. It sets up the image name and tags based on the event type and other parameters. For example, it generates different tags based on the branch name or if it's a pull request.
    d. Login to GitHub Container Registry: This step logs in to the GitHub Container Registry (GHCR) using the GitHub actor's username and a GitHub token. The token is provided by the system as ${{ secrets.GITHUB_TOKEN }}.
    e. Push to GitHub Packages: This step uses the "docker/build-push-action" GitHub Action to build and push the Docker image to GitHub Packages. It specifies the platform as "linux/amd64" and the tags to be pushed, which are obtained from the output of the "Docker meta" step.
    This GitHub workflow automates the process of building and pushing a Docker image to GitHub Packages whenever there is a push to the "master" or "development" branches or when a new tag matching the pattern "v1.**" is created. Additionally, it also handles pushing the image when a pull request is created to the "development" branch.

    Step 4. Push project to github#

    image.png
    After the code is pushed, GitHub workflow will automatically build the Docker image and push it to the GitHub Container Registry.
    image.png

    Step 5. Create docker compose on staging VM#

    image.png
    Access the staging VM.
    Navigate to the "diary bunda" directory.
    Create a directory with the name of the project you want to deploy.
    Add the "docker-compose.yml" file.
    Example docker-compose.yml file :
    Add the ".env" file.
    Example .env file
    The ".env" file is used to override the environment variables present in the "application.properties" file.

    Step 6. Up docker compose#

    On the project directory folder in the staging VM, execute the following command:
    sudo docker-compose up -d
    The project has been successfully deployed to the staging server.
    Access the API using the following URL:
    staging.diarybunda.co.id/auth-service
    Modified at 2023-07-26 07:48:06
    Previous
    Diarybunda Documentation
    Next
    Required Dependencies
    Built with