跳過到頁腳內容
使用 IRONSECUREDOC

Docker Build Push Action(開發者如何工作)

What is Docker?

Docker is an open-source powerhouse that makes building, deploying, and managing applications easier by placing them into lightweight, portable containers. The containers package up an application and its dependencies including libraries, configuration files, and so on so that it can even run across environments. This eliminates all compatibility issues, meaning the application will act the same on a developer's laptop as on a server or in the cloud. It simplifies the development, testing, and scaling process by building the tools efficiently, shipping, and running containers, hence managing the resources more simplistically.

Docker Build Push Action (How it Works for Developers): Figure 1 - Docker

What is Docker Image?

Images are the Docker-type blueprints that carry the consistent runtime environments. Developers can utilize ready-to-use images from Docker Hub, a public registry, or create their own Docker images. Tools like Docker Compose and Kubernetes extend Docker's capabilities even more by adding simple orchestrations of multi-container setups or managing complex scaling needs more platforms.

Why use the Docker Build Push Action?

Frictionless Automation

Building and pushing Docker images manually is exposed, error-prone, and time-consuming. Automating these steps ensures predictability and adds hours to the bottom line, especially when the team scales or updates are more frequent.

Frictionless Integration

The Docker Build Push Action works out of the box with GitHub repositories to create workflows around events such as code pushes, pull requests, or a schedule.

Standard Building of Images

Automation ensures that every time Docker images are built, they are the same; hence, reducing errors/discrepancies across multiple environments such as development, staging, and production.

Easy Deployment

With the automated building of Docker images with the build, and their push to the repositories, the deployment can get relatively easy. Tools like Kubernetes or Docker Swarm can be used to pull or build multi-platform images straight from the Docker registry, and hence reduce downtime.

How the Docker Build Push Action Works

The Build and Push Docker action does three core things:

  1. Set Up Docker Login: Container registry authentication to securely push Docker images.
  2. Image Build: Runs Docker build commands using a Dockerfile which contains instructions.
  3. Push to Registry: It pushes the built image to a target container registry.

These steps are defined in a GitHub Actions workflow file (.github/workflows/your-workflow.yml), where you specify triggers, build configurations, and registry credentials.

Implement Docker Build Push Action

1: Prepare Your Repository

  • Add a Dockerfile describing the containerized application.
  • Add any configuration files or scripts required for the build.
# Use Node.js as the base image
FROM node:14

# Set the working directory
WORKDIR /app

# Copy package.json and install dependencies
COPY package.json .
RUN npm install

# Copy the application code
COPY . .

# Expose the application’s port
EXPOSE 3000

# Start the application
CMD ["npm", "start"]

2: Add Registry Credentials as GitHub Secrets

To build and push Docker images to a container registry, you need credentials. Add these as GitHub Secrets:

  • Go into your repository settings on GitHub.
  • Go to Secrets and Variables > Actions.

Add the following secrets:

  • USERNAME: Your Docker Hub username.
  • PASSWORD: Your Docker Hub access token or password.

For other registries, this is similar but sometimes requires extra credentials, for example, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for Amazon ECR.

3: Create GitHub Actions workflow

Add the below line on the YAML workflow file in .github/workflows/docker-build-push.yml.

name: Docker Build and Push

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # Step 1: Check out the repository
      - name: Checkout code
        uses: actions/checkout@v3

      # Step 2: Log in to Docker Hub
      - name: Log in to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}

      # Step 3: Build and push the Docker image
      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: username/repository:latest
name: Docker Build and Push

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # Step 1: Check out the repository
      - name: Checkout code
        uses: actions/checkout@v3

      # Step 2: Log in to Docker Hub
      - name: Log in to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}

      # Step 3: Build and push the Docker image
      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: username/repository:latest
YAML

Push to Main: The workflow will trigger every push that occurs to the main branch.

Checkout Code: Utilize the actions/checkout action to check out the repository.

Login to Registry: Authenticate with Docker Hub using the provided secrets.

Build and Push: It runs the Docker Build Push Action that will build the image from the current directory until the context and push it to username/repository: latest.

Commit the workflow file to your repository. With a simple push, the workflow will trigger to build the image and push it into your specified registry.

What is IronSecureDoc?

IronSecureDoc is a newly developed product of Iron Software specifically designed for securing digital documents, mainly PDFs, through quite robust encryption and controls. This will further enable an organization to install advanced encryption protocols like AES-256 so that the said sensitive information cannot be viewed without authorized permission. That means the said document can only be opened by the authorized user because the printing, editing, and copying of it have restrictions along with custom permissions. Also, password protection and digital signings enhance security and integrity in the documents and watermarking.

Docker Build Push Action (How it Works for Developers): Figure 2 - IronSecureDoc: The PDF Security and Compliance Server

IronSecureDoc is developer-friendly and can comfortably house applications via Docker or other programming environments, hence should be able to adapt to many business workflows. For instance, in the health, financial, and legal sectors, confidentiality of the documents means everything. IronSecureDoc combines the features of encryption and control of documents within an organization with ensuring safekeeping that allows for compliance, easy, and safe sharing with a partner or client outside.

How IronSecureDoc Works

IronSecureDoc is given out as a Docker container and provides exposure to the build functionalities by API endpoints which will keep it scalable and uniform. Developers pull a pre-built Docker image of IronSecureDoc from a container registry and include it in their applications.

Document Workflow with IronSecureDoc

  • Create and push the IronSecureDoc container using Docker Build Push Action.
  • Deployment of the same container on a cloud platform like AWS ECS or Kubernetes.
  • Integrate your application to communicate with IronSecureDoc for any document operation.

Install and Run IronSecureDoc

To pull the IronSecureDoc Docker image from the GitHub repository below, at the Command Prompt or in an open terminal window, run the following command.

docker pull ironsoftwareofficial/ironsecuredoc
docker pull ironsoftwareofficial/ironsecuredoc
SHELL

Docker Build Push Action (How it Works for Developers): Figure 3 - Pull Docker Image

After pulling an image from the Docker container, we have another command to start the IronSecureDoc, an operating container.

docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
SHELL

The above Docker run command will create a container instance of the IronSecureDoc.

Using IronSecureDoc

The REST API of IronSecureDoc has been discussed elsewhere, but basically, it allows the user to redact, certify, and encrypt documents out of the box upon installation and firing up Docker. Here is the link to the documentation.

Docker Build Push Action (How it Works for Developers): Figure 4 - REST API

We could also encrypt a document by posting to the IronSecureDoc API like this:

curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/encrypt?user_password=demo' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@test.pdf;type=application/pdf'
curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/encrypt?user_password=demo' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@test.pdf;type=application/pdf'
SHELL

This will route the document automatically into IronSecureDoc, where it will get correctly encrypted.

Conclusion

All starts with Docker Build Push Action and IronSecureDoc. They merge two very powerful tools that unlock the ability to containerize workflows with automated and scalable development being secure. Docker Build Push Action takes care of automated building and deployment in the development process of container images, and IronSecureDoc handles robust document security within those containers. It all comes to streamlined pipelines from developers and reliable performance across environments. Whether you're managing a deployment of applications or secure sensitive documents, these tools in your workflow are about to move you toward modern efficient software development.

IronSecureDoc: where document-specific security features can be added, including file encryption, access controls, and authentication of the authenticity of the document using digital signatures. Together, Docker certificates and IronSecureDoc provide full-cycle security, protecting everything from infrastructure to sensitive data stored. To learn more about the license of IronSecureDoc, visit the licensing page. For information about many of the products from Iron Software, follow this library suite link.

常見問題解答

怎樣在 C# 中將 HTML 轉換為 PDF?

您可以使用 IronPDF 的 RenderHtmlAsPdf 方法將 HTML 字符串轉換為 PDF。您還可以使用 RenderHtmlFileAsPdf 將 HTML 文件轉換為 PDF。

什麼是 Docker?

Docker 是一個開源平台,通過使用容器簡化應用程序的構建、部署和管理。這些容器將應用程序及其依賴包裝在一起,確保跨不同環境的一致行為。

Docker Build Push Action 如何精簡工作流程過程?

Docker Build Push Action 自動執行 GitHub 存儲庫中 Docker 映像的構建和推送,減少錯誤並節省時間。它創建由代碼推送或拉取請求等事件觸發的工作流程。

為什麼 Docker 對開發者有用?

Docker 對開發者有用,因為它將應用程序封裝在容器中,確保一致的性能並減少跨不同環境的兼容性問題。這精簡了開發、部署和管理過程。

使用 Docker 容器有什麼好處?

Docker 容器提供了便攜性、可擴展性和環境一致性的優勢。它們將應用程序及其依賴封裝在一起,減少了兼容性問題並提高了部署效率。

IronSecureDoc 如何確保文件安全?

IronSecureDoc 使用如 AES-256 等強大的加密技術來保護數字文件,並具有密碼保護和數字簽名等功能。它在需要高機密性的領域尤為有用,如醫療和金融。

IronSecureDoc 可以集成到現有的工作流程中嗎?

是的,IronSecureDoc 可以作為 Docker 容器運行並通過 API 端點提供功能,因此能夠靈活且容易地與各類部署場景集成到現有工作流程中。

Docker Build Push Action 如何提高部署效率?

Docker Build Push Action 通過自動化構建和推送 Docker 映像的過程,提高部署效率,確保一致的映像創建並通過與如 Kubernetes 平台的集成減少停機時間。

Docker 映像在應用程序部署中扮演著什麼角色?

Docker 映像作為容器的藍圖,包含應用程序及其依賴,確保跨不同環境的一致性,是可靠應用程序部署的關鍵。

我如何使用 GitHub Actions 自動化 Docker 映像的構建?

要使用 GitHub Actions 自動化 Docker 映像構建,創建一個工作流程文件,指定像代碼推送這樣的觸發器,使用 Docker 登錄與構建操作,並將構建的映像推送到註冊表。這種自動化簡化了構建與部署過程。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。