Skip to content

Commit 9ab9dd3

Browse files
authored
Merge pull request #289 from github/docker-multi
Add multi stage build Dockerfile that compiles rsync from the source rsync repository
2 parents cfaa9a7 + f168209 commit 9ab9dd3

File tree

3 files changed

+102
-12
lines changed

3 files changed

+102
-12
lines changed

.github/workflows/docker-image.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17-
- name: Build the Debian Docker image
17+
- name: Build the Ubuntu Docker image
1818
run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID}
1919
- name: Build the Alpine Docker image
2020
run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID}
21-
- name: Run tests in Debian Docker image
22-
run: docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version
21+
- name: Run tests in Ubuntu Docker image
22+
run: |
23+
docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version
24+
docker run backup-utils:${GITHUB_RUN_ID} rsync --version
2325
- name: Run tests in Alpine Docker image
24-
run: docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version
25-
26+
run: |
27+
docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version
28+
docker run backup-utils-alpine:${GITHUB_RUN_ID} rsync --version
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update Rsync Tag in Dockerfile
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Runs daily at 00:00
6+
7+
jobs:
8+
update-rsync-tag:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
15+
- name: Get latest rsync tag
16+
id: latest_tag
17+
run: |
18+
curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[0].name' | xargs -I {} echo "::set-output name=latest_tag::{}"
19+
20+
- name: Update Dockerfile with latest tag
21+
run: |
22+
sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile
23+
24+
- name: Create Pull Request for tag update
25+
uses: peter-evans/create-pull-request@v3
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
commit-message: "Update rsync tag in Dockerfile"
29+
title: "Update rsync tag in Dockerfile"
30+
body: "This PR updates the rsync tag in the Dockerfile to the latest tagged version."
31+
branch: "update-rsync-tag"
32+
base: "master"
33+
path: "."
34+
labels: "automated-update,rsync"

Dockerfile

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,71 @@
1-
FROM ubuntu:focal
1+
# Multi stage build for backup-utils
2+
# Build layer is for compiling rsync from source
3+
# Runtime layer is for running backup-utils
4+
# https://docs.docker.com/develop/develop-images/multistage-build/
5+
# https://docs.docker.com/engine/userguide/eng-image/multistage-build/
26

3-
RUN apt-get -q -y update && \
4-
apt-get install -y --no-install-recommends \
5-
tar \
7+
# Build layer
8+
FROM ubuntu:focal AS build
9+
10+
# Install build dependencies
11+
RUN apt-get update && apt-get install --no-install-recommends -y \
12+
gcc \
13+
g++ \
14+
gawk \
15+
autoconf \
16+
make \
17+
automake \
18+
python3-cmarkgfm \
19+
acl \
20+
libacl1-dev \
21+
attr \
22+
libattr1-dev \
23+
libxxhash-dev \
24+
libzstd-dev \
25+
liblz4-dev \
26+
libssl-dev \
27+
git \
628
jq \
7-
rsync \
29+
curl \
30+
tar \
31+
gzip \
832
ca-certificates \
9-
ssh \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
# Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag
36+
ARG RSYNC_TAG=v3.2.7
37+
RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz
38+
RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} --strip-components=1 && ls -la
39+
# Change to the working directory of the rsync source
40+
WORKDIR /rsync-${RSYNC_TAG}
41+
RUN ls -la && ./configure
42+
RUN make
43+
RUN make install
44+
45+
# Reset working directory
46+
WORKDIR /
47+
48+
# Runtime layer
49+
FROM ubuntu:focal AS runtime
50+
51+
# Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer.
52+
RUN apt-get update && apt-get install --no-install-recommends -y \
53+
bash \
1054
git \
55+
openssh-client \
56+
jq \
1157
moreutils \
12-
gawk \
58+
gawk \
59+
ca-certificates \
60+
xxhash \
1361
&& rm -rf /var/lib/apt/lists/*
1462

63+
# Copy rsync from build layer
64+
COPY --from=build /usr/local/bin/rsync /usr/local/bin/rsync
65+
66+
# Copy backup-utils from repository into /backup-utils
1567
COPY ./ /backup-utils/
68+
1669
WORKDIR /backup-utils
1770

1871
RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init

0 commit comments

Comments
 (0)