Skip to content

Commit

Permalink
update dependency and blog on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s committed Nov 24, 2024
1 parent 82f4932 commit b0f1855
Show file tree
Hide file tree
Showing 4 changed files with 2,405 additions and 427 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
slug: automating-docusaurus-deployment-with-github-actions-and-nanocl
title: Automating docusaurus deployment with GitHub Actions and Nanocl
slug: automating-deployment-with-github-actions-and-nanocl
title: Automating deployment with GitHub Actions and Nanocl
description: Learn how to automate your CI/CD pipeline with GitHub Actions and Nanocl. This guide walks you through setting up seamless deployments, making it easier to deploy your applications with minimal effort. Whether you're new to CI/CD or an experienced developer, this post will show you how to streamline your workflow using two powerful open-source tools.
image: /img/cloud.webp
authors: [leone]
tags: [ci/cd, github actions, devops, automation, nanocl, deployment, open source, cloud infrastructure, docker, software development]
keywords: [CI/CD, GitHub Actions, automation, Nanocl, deployment, software development, DevOps, continuous integration, continuous delivery, cloud infrastructure]
---

Learn how to automate your CI/CD pipeline with GitHub Actions and Nanocl. This guide walks you through setting up seamless deployments, making it easier to deploy your applications with minimal effort. Whether you're new to CI/CD or an experienced developer, this post will show you how to streamline your workflow using two powerful open-source tools.
Learn how to automate your deployment with GitHub Actions and Nanocl. This guide walks you through setting up seamless deployments, making it easier to deploy your applications with minimal effort. Whether you're new to CI/CD or an experienced developer, this post will show you how to streamline your workflow using powerful open-source tools.


<!-- truncate -->

![nanocl-devops-meme](/img/nanocl-devops-meme.jpg)

## Introduction

Continuous Integration and Continuous Deployment (CI/CD) are essential practices in modern software development. They help automate the process of building, testing, and deploying applications, making it easier to deliver high-quality software quickly and efficiently. GitHub Actions is a powerful tool that allows you to automate your CI/CD pipeline directly from your GitHub repository. Nanocl is a containers and virtual machine orchestrator that simplifies the deployment process by providing a unified interface for managing your infrastructure.

We will take a look and how we did setup our CI/CD pipeline with Github Actions and Nanocl for the deployment of [next-hat][docs.next-hat.com] and and [ntex.rs][ntex.rs] documentation.
In this blog we will showcase how we did setup our CI/CD pipeline with Github Actions and Nanocl for the deployment of [next-hat][docs.next-hat.com] and and [ntex.rs][ntex.rs] documentation that use docusaurus.

## Prerequisites

Expand All @@ -29,7 +32,11 @@ Before we get started you need a few things:
- Docker installed on your local machine and server (you can find the installation instructions [here][get-docker])
- Nanocl installed on your server (you can find the installation instructions [here][get-nanocl])

## Creating a Nginx Configuration File
## Creating the container image

We will take a look on how to create the container image for the deployment of the documentation of [next-hat][docs.next-hat.com] and [ntex.rs][ntex.rs] that use docusaurus. If you already know how to setup a docker container image you can skip this section.

### Creating a Nginx Configuration File

We use `nginx` as a web server to serve the static files generated by docusaurus. The `server.nginx` file contains the configuration for the nginx server. You can replace it with your own configuration file to match your use case.

Expand Down Expand Up @@ -83,7 +90,7 @@ Let's break down the `server.nginx` configuration file:

This configuration file optimizes the Nginx server for serving static files and improves performance by enabling gzip compression and caching.

## Creating a Dockerfile
### Creating a Dockerfile

A [Dockerfile][dockerfile] is a text document that contains all the commands needed to build a Docker image. It specifies the base image to use, the commands to run, and the files to copy into the image. In this guide, we will create a Dockerfile for a docusaurus website. You can replace the commands with the ones needed for your project.

Expand Down Expand Up @@ -143,7 +150,7 @@ Let's break down the Dockerfile:

This Dockerfile creates a multi-stage build that first builds the application using Node.js and then copies the static files into an Nginx image. This approach reduces the size of the final image and improves performance by separating the build dependencies from the runtime dependencies.

## Building and Running the Docker Image Locally
### Building and Running the Docker Image Locally

Before deploying your application to your server, you should test the Docker image locally to ensure that it works as expected. You can build and run the Docker image on your local machine using the following commands:

Expand All @@ -160,7 +167,7 @@ If everything works as expected, you should see a production version of your doc

Nanocl is a powerful tool that simplifies the deployment process by providing a unified interface for managing your infrastructure. You can use Nanocl to deploy your applications to your server with minimal effort. In this guide, we will show you how to set up Nanocl on your server and deploy your application using a simple configuration file.

First, you need to install Nanocl on your server. You can find the installation instructions [here](/manuals/nanocl/install/overview). Once you have installed Nanocl, you can create a configuration file for your application. This file will contain the settings for your application, such as the image name, port number, and environment variables.
First, you need to install Nanocl on your server. You can find the installation instructions [here][nanocl-install]. Once you have installed Nanocl, you can create a configuration file for your application. This file will contain the settings for your application, such as the image name, port number, and environment variables.

By default once installed Nanocl is only accessible via `/run/nanocl/nanocl.sock`. You can use a proxy rule to expose it to the public internet, however, exposing it to the public without a self signed SSL/TLS certificate is not recommended.
It could allow an attacker to take control of your server.
Expand Down Expand Up @@ -300,7 +307,7 @@ jobs:
ghcr.io/${{ github.repository_owner }}/documentation:${{ env.PACKAGE_VERSION }}
```

This workflow will run every time you push code to your repository. It will build a docker image from your code, tag it with the latest version from your `package.json` file, and push it to the GitHub Container Registry. You can replace `documentation` with your image name.
This workflow will run every time you merge code in the master branch of your repository. It will build a docker image from your code, tag it with the latest version from your `package.json` file, and push it to the GitHub Container Registry. You can replace `documentation` with your image name.

### Deploying the Application with Nanocl

Expand All @@ -325,7 +332,7 @@ jobs:
- name: Install nanocl cli
run: |
wget https://github.com/next-hat/nanocl/releases/download/nanocl-0.16.1-nightly/nanocl_0.16.1_amd64.deb
wget https://github.com/next-hat/nanocl/releases/download/nanocl-0.16.2/nanocl_0.16.2_amd64.deb
sudo dpkg -i nanocl_0.16.1_amd64.deb
rm nanocl_0.16.1_amd64.deb
Expand Down Expand Up @@ -355,8 +362,6 @@ nanocl state apply -fs https://nhnr.io/v0.16/sys/certbot.yml -- --email contact@

## Conclusion

In this guide, we showed you how to automate your CI/CD pipeline with GitHub Actions and Nanocl. We walked you through setting up seamless deployments, making it easier to deploy your applications with minimal effort. Whether you're new to CI/CD or an experienced developer, this post showed you how to streamline your workflow using two powerful open-source tools.

By following the steps outlined in this guide, you can automate the deployment of your applications to your server with minimal effort. This will help you deliver high-quality software quickly and efficiently, making it easier to manage your infrastructure and deploy your applications with confidence.

Now that you know how to automate your deployment with GitHub Actions and Nanocl, why not give it a try with your own project? Let us know how it goes or if you have any questions!
Expand All @@ -371,4 +376,5 @@ You can join our [discord server][discord] if you have any questions or need hel
[get-docker]: https://docs.docker.com/get-docker
[get-nanocl]: /manuals/nanocl/install/overview
[dockerfile]: https://docs.docker.com/reference/dockerfile/
[discord]: https://discord.gg/WV4Aac8uZg
[discord]: https://discord.gg/WV4Aac8uZg
[nanocl-install]: /manuals/nanocl/install/overview
Loading

0 comments on commit b0f1855

Please sign in to comment.