Skip to content

Commit

Permalink
Add support for arm64 architecture
Browse files Browse the repository at this point in the history
Among other breaking changes.
  • Loading branch information
felipecrs committed Mar 3, 2024
1 parent 3a5213e commit d72a4d1
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

*.x.c
dist/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Newer versions

Please check the [releases page](https://github.com/felipecrs/fixdockergid/releases) for the changelog of newer versions.

## 0.6.0

- Cleanup and refactor code a little bit, enable all ShellCheck optional checks and fix them.
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ RUN --mount=type=bind,source=_fixdockergid.sh,target=/_fixdockergid.sh \
# Used by build.sh
FROM scratch AS dist

COPY --from=build /_fixdockergid /
ARG TARGETARCH
COPY --from=build /_fixdockergid /dist/_fixdockergid.linux_${TARGETARCH}


# Contains non-root user and docker-cli
Expand Down Expand Up @@ -48,7 +49,7 @@ RUN \
# Main image
FROM docker-cli AS main

COPY --from=bin / /usr/local/share/fixdockergid/
COPY --from=build /_fixdockergid /usr/local/share/fixdockergid/
RUN --mount=source=install.sh,target=/tmp/install.sh \
/tmp/install.sh

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ USER root

# Replace with your non-root user name
ARG USERNAME="rootless"
# Replace with a git tag or commit hash
ARG FIXDOCKERGID_COMMIT="HEAD"
# Replace with a git tag
ARG FIXDOCKERGID_VERSION="0.7.0"

RUN curl -fsSL "https://raw.githubusercontent.com/felipecrs/fixdockergid/${FIXDOCKERGID_COMMIT}/install.sh" | sh -
RUN curl -fsSL "https://github.com/felipecrs/fixdockergid/raw/v${FIXDOCKERGID_VERSION}/install.sh" | sh -

ENTRYPOINT [ "fixdockergid" ]

Expand Down
Binary file removed _fixdockergid
Binary file not shown.
24 changes: 23 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,26 @@

set -euxo pipefail

docker buildx build --target=bin --platform=amd64 -o . .
rm -rf dist

docker buildx build --target=dist --platform=amd64 -o . .
docker buildx build --target=dist --platform=arm64 -o . .

set +x

echo "Release on GitHub with:" >&2
# shellcheck disable=SC2016
echo ' gh release create v${VERSION?} --title v${VERSION} dist/*' >&2

echo "Push to Docker Hub with:" >&2
# shellcheck disable=SC2016
cat <<'EOF' >&2
docker run --privileged --rm --pull=always tonistiigi/binfmt --install arm64 \
&& docker buildx rm --force multi-arch-builder \
&& docker buildx create --name multi-arch-builder \
&& docker buildx build . --builder multi-arch-builder --pull \
--tag felipecrs/fixdockergid:latest \
--tag felipecrs/fixdockergid:${VERSION?} \
--platform=linux/amd64,linux/arm64 \
--push
EOF
6 changes: 3 additions & 3 deletions example.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ RUN \
# Clean up \
&& rm -rf /var/lib/apt/lists/*

# Replace with a git tag or commit hash
ARG FIXDOCKERGID_COMMIT='HEAD'
# Replace with a git tag
ARG FIXDOCKERGID_VERSION="0.7.0"
# You must also set ARG USERNAME
RUN curl -fsSL "https://raw.githubusercontent.com/felipecrs/fixdockergid/${FIXDOCKERGID_COMMIT}/install.sh" | sh -
RUN curl -fsSL "https://github.com/felipecrs/fixdockergid/raw/v${FIXDOCKERGID_VERSION}/install.sh" | sh -

ENTRYPOINT [ "fixdockergid" ]

Expand Down
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ if [ -f "${_fixdockergid_filename}" ]; then
# Used when building fixdockergid's Dockerfile
echo "Using existing ${fixdockergid_dir}/${_fixdockergid_filename}"
else
if [ -z "${FIXDOCKERGID_COMMIT:-}" ]; then
error "The FIXDOCKERGID_COMMIT environment variable must be set."
if [ -z "${FIXDOCKERGID_VERSION:-}" ]; then
error "The FIXDOCKERGID_VERSION environment variable must be set."
fi
echo "Downloading ${_fixdockergid_filename} to ${fixdockergid_dir}/${_fixdockergid_filename}"
_fixdockergid_url="https://raw.githubusercontent.com/felipecrs/fixdockergid/${FIXDOCKERGID_COMMIT}/_fixdockergid"
_fixdockergid_url="https://github.com/felipecrs/fixdockergid/releases/download/v${FIXDOCKERGID_VERSION}/_fixdockergid.linux_$(dpkg --print-architecture)"
if command -v curl >/dev/null; then
curl -fsSL -o "${_fixdockergid_filename}" "${_fixdockergid_url}"
else
Expand All @@ -46,7 +46,7 @@ if ! command -v fixuid >/dev/null; then
fi
fixuid_version='0.6.0'
echo "Installing fixuid v${fixuid_version}"
fixuid_url="https://github.com/boxboat/fixuid/releases/download/v${fixuid_version}/fixuid-${fixuid_version}-linux-amd64.tar.gz"
fixuid_url="https://github.com/boxboat/fixuid/releases/download/v${fixuid_version}/fixuid-${fixuid_version}-linux-$(dpkg --print-architecture).tar.gz"
fixuid_filename='fixuid.tar.gz'
if command -v curl >/dev/null; then
curl -fsSL -o "${fixuid_filename}" "${fixuid_url}"
Expand Down

0 comments on commit d72a4d1

Please sign in to comment.