~nickbp/twitch-rss

30d72f177086773c3b29034fc37ad6a70892a660 — Nick Parker 3 months ago e145e48
Add CI and docker definitions
3 files changed, 35 insertions(+), 0 deletions(-)

A .build.yml
A Dockerfile
A docker-build.sh
A .build.yml => .build.yml +9 -0
@@ 0,0 1,9 @@
image: alpine/edge
packages:
- cargo
environment:
  repo: twitch-rss
tasks:
- build: |
    cd $repo/
    cargo test --all

A Dockerfile => Dockerfile +8 -0
@@ 0,0 1,8 @@
# Builds an image containing the binary and little else.
FROM rust:slim
COPY . /twitch-rss
RUN cd /twitch-rss && cargo build --all-targets --release

FROM debian:buster-slim
COPY --from=0 /twitch-rss/target/release/twitch-rss /twitch-rss
RUN chmod +x /twitch-rss

A docker-build.sh => docker-build.sh +18 -0
@@ 0,0 1,18 @@
#!/bin/bash

set -euo pipefail
IFS=$'\n\t'

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $SCRIPT_DIR

PROJ_NAME=$(basename $SCRIPT_DIR)

DOCKER_REGISTRY=${DOCKER_REGISTRY:=docker.io}
DOCKER_REPOSITORY=${DOCKER_REPOSITORY:="nickbp/${PROJ_NAME}:"}
DOCKER_BUILD=${DOCKER_BUILD:="docker buildx build --push --platform linux/amd64,linux/arm64"}

# Get 7-character commit SHA (note: doesn't detect dirty commits)
COMMIT_SHA=$(git rev-parse HEAD | cut -b 1-7)

time /bin/sh -c "$DOCKER_BUILD -t ${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}${COMMIT_SHA} ."