Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Publish Docker image (WIP) #217

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
!/app
/app/cli_internal.*.in
!/include
!/scripts
!/src
!configure
!AUTHORS
!Makefile
!LICENSE
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,37 @@ jobs:
TRIPLET: ${{ env.AMD64_MACOSX_GCC }}
run: |
./scripts/ci-update-homebrew-tap.sh

docker:
needs: [tag, ci]
runs-on: ubuntu-latest

env:
TAG: ${{ needs.tag.outputs.TAG }}

steps:
- name: Checkout
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 GitHub Container Registry
uses: docker/login-action@v3
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: false
tags: |
zsv:${{ env.TAG }}
zsv:latest
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM alpine:latest AS build

LABEL maintainer="Liquidaty"
LABEL description="zsv: tabular data swiss-army knife CLI + world's fastest (simd) CSV parser"
LABEL url="https://github.com/liquidaty/zsv"

RUN apk add --no-cache gcc make musl-dev perl

WORKDIR /zsv
COPY . .

RUN \
PREFIX=amd64-linux-musl \
CC=gcc \
MAKE=make \
ARTIFACT_DIR=artifacts \
RUN_TESTS=false \
STATIC_BUILD=1 \
SKIP_ZIP_ARCHIVE=true \
SKIP_TAR_ARCHIVE=true \
./scripts/ci-build.sh

FROM scratch

WORKDIR /zsv
COPY --from=build /zsv/amd64-linux-musl/bin/zsv .
COPY --from=build /zsv/AUTHORS /zsv/LICENSE ./

ENTRYPOINT [ "./zsv" ]
5 changes: 4 additions & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,17 @@ clean-util-lib:
clean-lib:
@rm -rf ${BUILD_DIR}-external

clean: clean-obj
clean: clean-obj clean-internal
rm -rf ${BUILD_DIR}
${MAKE} -C test clean CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG}

clean-obj:
rm -rf ${BUILD_DIR}/bin ${INIH_OBJECT} ${JSONWRITER_OBJECT} ${UTF8PROC_OBJECT}
rm -rf external/utf8proc-2.6.1

clean-internal:
$(RM) cli_internal.c.in cli_internal.h.in

${UTF8PROC_SRC}/utf8proc.c ${UTF8PROC_SRC}/utf8proc.h: ${THIS_MAKEFILE_DIR}/external/utf8proc-2.6.1.tar.gz
@cd external && tar xf $< && chown -R `whoami` utf8proc-2.6.1
@touch $@
44 changes: 29 additions & 15 deletions scripts/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ if [ "$RUN_TESTS" != true ]; then
RUN_TESTS=false
fi

if [ "$SKIP_ZIP_ARCHIVE" != true ]; then
SKIP_ZIP_ARCHIVE=false
fi

if [ "$SKIP_TAR_ARCHIVE" != true ]; then
SKIP_TAR_ARCHIVE=false
fi

#JQ_DIR="$PWD/jq"
#JQ_PREFIX="$JQ_DIR/build"
#JQ_INCLUDE_DIR="$JQ_PREFIX/include"
Expand All @@ -33,6 +41,8 @@ echo "[INF] LDFLAGS: $LDFLAGS"
echo "[INF] MAKE: $MAKE"
echo "[INF] RUN_TESTS: $RUN_TESTS"
echo "[INF] ARTIFACT_DIR: $ARTIFACT_DIR"
echo "[INF] SKIP_ZIP_ARCHIVE: $SKIP_ZIP_ARCHIVE"
echo "[INF] SKIP_TAR_ARCHIVE: $SKIP_TAR_ARCHIVE"
#echo "[INF] JQ_DIR: $JQ_DIR"
#echo "[INF] JQ_PREFIX: $JQ_PREFIX"
#echo "[INF] JQ_INCLUDE_DIR: $JQ_INCLUDE_DIR"
Expand Down Expand Up @@ -74,20 +84,24 @@ echo "[INF] Built successfully!"

mkdir -p "$ARTIFACT_DIR"

ZIP="$PREFIX.zip"
echo "[INF] Compressing [$ZIP]"
cd "$PREFIX"
zip -r "$ZIP" .
ls -Gghl "$ZIP"
cd ..
mv "$PREFIX/$ZIP" "$ARTIFACT_DIR"
echo "[INF] Compressed! [$ZIP]"

TAR="$PREFIX.tar.gz"
echo "[INF] Compressing [$TAR]"
tar -czvf "$TAR" "$PREFIX"
ls -Gghl "$TAR"
mv "$TAR" "$ARTIFACT_DIR"
echo "[INF] Compressed! [$TAR]"
if [ "$SKIP_ZIP_ARCHIVE" = false ]; then
ZIP="$PREFIX.zip"
echo "[INF] Compressing [$ZIP]"
cd "$PREFIX"
zip -r "$ZIP" .
ls -Gghl "$ZIP"
cd ..
mv "$PREFIX/$ZIP" "$ARTIFACT_DIR"
echo "[INF] Compressed! [$ZIP]"
fi

if [ "$SKIP_TAR_ARCHIVE" = false ]; then
TAR="$PREFIX.tar.gz"
echo "[INF] Compressing [$TAR]"
tar -czvf "$TAR" "$PREFIX"
ls -Gghl "$TAR"
mv "$TAR" "$ARTIFACT_DIR"
echo "[INF] Compressed! [$TAR]"
fi

echo "[INF] --- [DONE] ---"