Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: ci-cd

RSS

Node.js backend Dockerfile example

This article introduces two Docker image build solutions based on Node.js, aiming to optimize image size and resolve environment dependency issues through layered build techniques. The first solution is designed for simple scenarios and adopts a three-stage build process: it first installs development dependencies, then executes build commands to generate artifacts, and finally integrates them into the production environment, striving to minimize the final image size. The second solution targets complex scenarios, focusing on resolving Linux graphics library dependencies required by the Canvas library, the Python runtime environment, and the installation of Chinese fonts. This solution configures domestic mirror sources to accelerate downloads and pre-installs Python and necessary system libraries in the production stage, ensuring the completeness and stability of the application runtime. Both solutions follow best practices by using multi-stage builds to isolate development, build, and production environments, effectively reducing redundant files in the final delivered image. Additionally, they ensure service availability through health check mechanisms, providing practical containerized deployment references for Node.js projects of varying complexity.

Views 144
ci-cd devops docker dockerfile fonts multistage-build node nodejs python web-service

GitLab Pipeline DingTalk Notification

This document describes how to integrate DingTalk bot notifications into a GitLab CI pipeline. The author created a base repository, `share/gitlab-ci`, which contains a `dingtalk.yml` template file. This file leverages GitLab Hook events to call the DingTalk API via `curl` to send messages. The core implementation includes defining global variables, validating the Access Token and URL-encoding the project address in the prepare stage, and constructing a Markdown message in the send stage that includes details such as task status, commit information, and the executor. It supports displaying different colors based on statuses like success or failure and includes jump buttons to view project and task details. In specific projects, this template is referenced using the `include` directive, and the `.dingtalk` configuration is inherited via `extends` in tasks across various stages, thereby enabling automated notifications for steps such as code inspection, building, and deployment. This solution addresses the previous issue where only repository information was recorded without pipeline notifications, achieving full-process visual feedback from task initiation to execution results. This enhances the transparency and collaboration efficiency of the DevOps workflow.

Views 341
ci-cd daily devops dingtalk integration gitlab gitlab ci

OpenAPI client generation

This article documents the selection process and practical experience of automatically generating SDKs based on OpenAPI metadata. The author compared three libraries: `autorest`, `swagger-codegen-cli`, and `@hey-api/openapi-ts`, ultimately choosing the latter due to its superior performance in frontend environment compatibility, code conciseness, and type reuse. This choice effectively reduces the workload of manually writing request code and improves development efficiency. Using a NestJS backend and Vue frontend as examples, the article details the complete technical pipeline: configuring `nest-cli.json` to extract DTO and Entity types, utilizing a GitHub Actions pipeline to start the service in a CI environment to retrieve metadata, invoking `@hey-api/openapi-ts` to generate the SDK, and pushing it to a separate sub-repository. The frontend wraps the `@hey-api/client-fetch` client to implement unified authentication interception and error handling, directly importing the generated types and functions within Pinia Stores to achieve type safety and code reuse. This workflow not only reduces the collaboration cost between frontend and backend teams but also minimizes format errors through standardized interface definitions. Although the currently auto-generated parameter validation feature has limitations, the overall solution offers significant advantages in terms of type safety and development efficiency.

Views 385
2024 ci-cd github openapi study swagger vue work

AutoQuery Usage and Deployment (GitHub Actions)

This article introduces the rapid development workflow based on the AutoQuery framework, covering key steps from environment initialization to production deployment. First, the `x` command-line tool is installed via `dotnet tool`, and the `x new` command is used to create a Web project. `autocrudgen` is then leveraged to automatically generate SQLite database models and basic code, simplifying backend development tasks. The deployment section details how to configure Docker and Docker Compose on an Ubuntu 22.04 server, including specific commands for updating system sources, adding the official Docker GPG key, and installing the latest CE version. The article also demonstrates how to use `x mix build` to generate an Nginx proxy configuration script, upload it to the server via `scp`, and start services using `docker compose` commands, thereby implementing an automated deployment solution based on GitHub Actions. Additionally, the text provides practical details such as Let's Encrypt email configuration, SSH connection parameters, and user permission settings, aiming to help developers efficiently build and deploy AutoQuery-based applications. A link to a related video tutorial is provided at the end for further learning.

Views 78
.Net ci-cd devops docker github nginx