🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 4 Min Lesezeit
0

Beginner’s Guide: Build, Push, and Deploy Docker Image with GitHub Actions

↗ Quelle (dev.to)
🗣️ Stimme:

In this post, we’ll introduce GitHub Actions and explain how to use them for automating Docker image builds, pushing images to a self-hosted registry, and deploying them to a remote server. This guide is tailored for beginners who want to start simple and expand their knowledge over time.




  1. What’s GitHub Actions?



GitHub Actions is a powerful tool for automating software workflows directly within your GitHub repository. It allows you to build, test, and deploy your code directly from GitHub. You define your automation tasks as YAML files within your repository, and these tasks run on GitHub’s hosted servers (or self-hosted runners if you prefer).



Why use GitHub Actions?




  • Seamless integration with GitHub repositories.

  • Customization: Create workflows tailored to your project needs.

  • Ease of use: Simple YAML configuration.




  1. What This Script Does



The given GitHub Actions script automates the CI/CD pipeline for building, tagging, and pushing a Docker image to a self-hosted registry, then deploying it to a remote server. Let’s dive into the main sections of the script and understand how each part works.



a. Checking Out the Code




CODE
- name: Checkout Code
uses: actions/checkout@v3






This step clones the repository into the GitHub Actions runner, enabling the workflow to access your project files.



b. Setting Up Docker Buildx




CODE
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2






Docker Buildx allows the runner to build multi-platform images and use advanced build features.



c. Configuring and Logging into the Docker Registry




CODE
- name: Add Registry to /etc/hosts
run: |
echo "${{ secrets.HOSTS_ENTRY }}" | sudo tee -a /etc/hosts

- name: Configure Docker for Insecure Registry
run: |
sudo mkdir -p /etc/docker
echo '{ "insecure-registries": ["https://harbor.example.com"] }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker

- name: Log in to Docker Registry
uses: docker/login-action@v2
with:
registry: harbor.example.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}






These steps set up Docker on the runner to connect to the self-hosted Harbor registry. It configures Docker to treat the registry as an insecure source (use this cautiously) and logs in using provided credentials.



d. Tagging with a Date-Time-Based Version




CODE
- name: Generate Date-Time-Based Tag
id: generate_tag
run: |
new_version=$(date -u +"v%Y.%m.%d.%H%M%S")
echo "Generated tag: $new_version"
echo "version=$new_version" >> $GITHUB_ENV






This step creates a version tag based on the current UTC date and time, ensuring unique version identifiers for each image build.



e. Building and Pushing the Docker Image




CODE
- name: Build Docker Image
run: |
PROJECT_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)
docker build -f .docker/Dockerfile \
-t harbor.example.com/${{ vars.PROJECT_NAME }}/$PROJECT_NAME:${{ env.version }} -t harbor.example.com/${{ vars.PROJECT_NAME }}/$PROJECT_NAME:latest .
env:
GITHUB_REPOSITORY: ${{ github.repository }}

- name: Push Docker Image
run: |
PROJECT_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)
docker push harbor.example.com/${{ vars.PROJECT_NAME }}/$PROJECT_NAME:${{ env.version }}
docker push harbor.example.com/${{ vars.PROJECT_NAME }}/$PROJECT_NAME:latest
env:
GITHUB_REPOSITORY: ${{ github.repository }}






This section builds the Docker image using the Dockerfile and tags it with both the generated version and latest. It then pushes the images to the Harbor registry.



f. Deploying to a Remote Server




CODE
- name: Deploy to Remote Server
if: success()
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DEPLOY_COMMANDS: ${{ secrets.DEPLOY_COMMANDS }}
run: |
echo "${SSH_PRIVATE_KEY}" > /tmp/private_key
chmod 600 /tmp/private_key
ssh -o StrictHostKeyChecking=no -i /tmp/private_key ${SSH_USERNAME}@${SSH_HOST} "${DEPLOY_COMMANDS}"
shell: bash






Finally, this step connects to a remote server via SSH and runs the deployment commands specified in the GitHub secret DEPLOY_COMMANDS. This helps automate the release process.



Below is an image of the complete GitHub Actions script:



.



Feel free to use this template as a starting point for automating your Docker workflows and deployment pipelines. With GitHub Actions, you can achieve seamless automation with just a few configuration steps!

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Beginner’s Guide: Build, Push, and Deploy Docker Image with GitHub Actions

Thematisch verwandte Begriffe: Beginners, Guide, Build, Push · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...