Skip to content

Commit

Permalink
Merge pull request #7 from kense-lab/action/docker-image
Browse files Browse the repository at this point in the history
add docker image github action
  • Loading branch information
Tuanzi1015 authored Jan 8, 2024
2 parents 2cbb8b2 + 41b7924 commit b53319e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 457 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker Image CI

on:
push:
branches:
- 'main'
release:
types: [ published ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: |
linux/amd64
linux/arm64
build-args: |
COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM python:3.10-slim AS base

LABEL maintainer="limeng.b@mininglamp.com"
LABEL maintainer="limeng1300881350@gmail.com"

COPY docker/sources.list /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends bash curl wget vim libmagic-dev \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --no-cache-dir poetry \
RUN pip install --no-cache-dir poetry \
&& poetry config virtualenvs.create false

COPY poetry.lock /env/poetry.lock
Expand Down
5 changes: 0 additions & 5 deletions docker/sources.list

This file was deleted.

Loading

0 comments on commit b53319e

Please sign in to comment.