반응형
How to build and push Docker images with GitHub Actions
Create a new repository for GitHub
new repository > Actions > set up a workflow yourself
Editing
main.yml editing
name: CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/actions-test:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
Dockerfile editing
FROM centos:7
LABEL website="sangchul.kr"
ENV PS1A="\[\e[33m\]\u\[\e[m\]\[\e[37m\]@\[\e[m\]\[\e[34m\]\h\[\e[m\]:\[\033[01;31m\]\W\[\e[m\]$ "
RUN echo 'PS1=$PS1A' >> ~/.bashrc
Repository(actions-test) source
728x90
Create an access token in the dockerhub
Account Settings > Security > New Access Token
Create a new repository in the docker hub
Repositories > Create
Register dockerhub access token as an environmental variable
repository > Settings > Secrets > New repository secret
- DOCKER_HUB_USERNAME
- DOCKER_HUB_ACCESS_TOKEN
When the source is committed, it automatically builds and pushes.
[Github]
[Dockerhub]
728x90
반응형
'리눅스' 카테고리의 다른 글
CentOS 7에서 Supervisor(supervisord 데몬)를 설치하는 방법 (0) | 2021.12.10 |
---|---|
쿠버네티스 실습 환경(플레이그라운드) (0) | 2021.12.07 |
Installing a package to use the Kafka command(kafka-topics.sh) (0) | 2021.11.30 |
도커 컨테이너 터미널 프롬프트(PS1) 색상 변경 (0) | 2021.11.25 |
HAProxy 로깅(haproxy logging) 설정하는 방법 (0) | 2021.11.24 |