Skip to content

Commit 0e612d4

Browse files
committed
Create build-docker-image.yml
1 parent df6fbf1 commit 0e612d4

File tree

6 files changed

+155
-0
lines changed

6 files changed

+155
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Docker Image Build
19+
20+
on:
21+
push:
22+
branches:
23+
- main
24+
tags:
25+
- '*'
26+
pull_request:
27+
28+
permissions:
29+
contents: read
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
build:
37+
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
38+
runs-on: ubuntu-24.04
39+
steps:
40+
- name: Login to Docker Registry
41+
uses: docker/login-action@v3
42+
with:
43+
registry: ${{ secrets.DOCKER_REGISTRY }}
44+
username: ${{ secrets.DOCKERHUB_USER }}
45+
password: ${{ secrets.DOCKERHUB_TOKEN }}
46+
47+
- name: Set Docker repository name
48+
run: echo "DOCKER_REPOSITORY=weizhouapache" >> $GITHUB_ENV
49+
50+
- uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
54+
- name: Set Docker image TAG
55+
run: echo "TAG=$(if [ "${{ github.event_name }}" = "pull_request" ];then echo "pr${{ github.event.pull_request.number}}"; elif [ "${{ github.ref_name }}" = "main" ];then echo "latest"; else echo ${{ github.ref_name }};fi)" >> $GITHUB_ENV
56+
57+
- name: Set Docker image FULL TAG
58+
run: echo "FULL_TAG=$(if [ "${{ secrets.DOCKER_REGISTRY }}" = "" ];then echo ${DOCKER_REPOSITORY}/docker-systemd:${TAG};else echo ${{ secrets.DOCKER_REGISTRY }}/${DOCKER_REPOSITORY}/docker-systemd:${TAG};fi)" >> $GITHUB_ENV
59+
60+
- name: Build the Docker image for docker-systemd
61+
run: docker build . --file Dockerfile.ubuntu24 --tag ${FULL_TAG}-ubuntu24
62+
- name: Push Docker image to Docker Registry
63+
run: docker push ${FULL_TAG}-ubuntu24
64+
65+
- name: Build the Docker image for docker-systemd
66+
run: docker build . --file Dockerfile.debian12 --tag ${FULL_TAG}-debian12
67+
- name: Push Docker image to Docker Registry
68+
run: docker push ${FULL_TAG}-debian12
69+
70+
- name: Build the Docker image for docker-systemd
71+
run: docker build . --file Dockerfile.alma9 --tag ${FULL_TAG}-alma9
72+
- name: Push Docker image to Docker Registry
73+
run: docker push ${FULL_TAG}-alma9
74+
75+
- name: Build the Docker image for docker-systemd
76+
run: docker build . --file Dockerfile.oracle9 --tag ${FULL_TAG}-oracle9
77+
- name: Push Docker image to Docker Registry
78+
run: docker push ${FULL_TAG}-oracle9
79+
80+
- name: Build the Docker image for docker-systemd
81+
run: docker build . --file Dockerfile.rocky9 --tag ${FULL_TAG}-rocky9
82+
- name: Push Docker image to Docker Registry
83+
run: docker push ${FULL_TAG}-rocky9
84+

Dockerfile.alma9

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM almalinux:9
2+
3+
ENV container docker
4+
5+
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
6+
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
7+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
8+
rm -f /etc/systemd/system/*.wants/*;\
9+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
10+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
11+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
12+
rm -f /lib/systemd/system/basic.target.wants/*;\
13+
rm -f /lib/systemd/system/anaconda.target.wants/*;
14+
15+
VOLUME [ "/sys/fs/cgroup" ]
16+
17+
CMD ["/usr/sbin/init"]

Dockerfile.debian12

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM debian:12
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt update && apt install -y ssh systemd
6+
7+
RUN echo exit 0 > /usr/sbin/policy-rc.d
8+
9+
CMD ["/sbin/init"]

Dockerfile.oracle9

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM oraclelinux:9
2+
3+
ENV container docker
4+
5+
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
6+
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
7+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
8+
rm -f /etc/systemd/system/*.wants/*;\
9+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
10+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
11+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
12+
rm -f /lib/systemd/system/basic.target.wants/*;\
13+
rm -f /lib/systemd/system/anaconda.target.wants/*;
14+
15+
VOLUME [ "/sys/fs/cgroup" ]
16+
17+
CMD ["/usr/sbin/init"]

Dockerfile.rocky9

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM rockylinux:9
2+
3+
ENV container docker
4+
5+
RUN dnf install -y systemd
6+
7+
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
8+
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
9+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
10+
rm -f /etc/systemd/system/*.wants/*;\
11+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
12+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
13+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
14+
rm -f /lib/systemd/system/basic.target.wants/*;\
15+
rm -f /lib/systemd/system/anaconda.target.wants/*;
16+
17+
VOLUME [ "/sys/fs/cgroup" ]
18+
19+
CMD ["/usr/sbin/init"]

Dockerfile.ubuntu24

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:24.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt update && apt install -y ssh systemd
6+
7+
RUN echo exit 0 > /usr/sbin/policy-rc.d
8+
9+
CMD ["/sbin/init"]

0 commit comments

Comments
 (0)