feat: add action workflows
This commit is contained in:
parent
2f9d63249a
commit
ffd21e62c9
34
.github/workflows/container.yml
vendored
Normal file
34
.github/workflows/container.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: Build Container Image
|
||||
on: [ push ]
|
||||
jobs:
|
||||
image:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKER: podman
|
||||
IMAGE_PREFIX: quay.io/ldcraft
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Upgrade Podman
|
||||
uses: gacts/install-podman@v1
|
||||
# reference: https://github.com/containers/podman/discussions/17868
|
||||
- name: Tar as root
|
||||
run: |
|
||||
sudo mv -fv /usr/bin/tar /usr/bin/tar.orig
|
||||
echo -e '#!/bin/sh\n\nsudo /usr/bin/tar.orig "$@"' | sudo tee -a /usr/bin/tar
|
||||
sudo chmod +x /usr/bin/tar
|
||||
- name: Cache Podman
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.local/share/containers
|
||||
~/.config/containers
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/*.Dockerfile', 'build_image.sh') }}
|
||||
- name: Login to Container Registry
|
||||
uses: redhat-actions/podman-login@v1
|
||||
with:
|
||||
registry: quay.io
|
||||
username: ${{ secrets.CONTAINER_USERNAME }}
|
||||
password: ${{ secrets.CONTAINER_PASSWORD }}
|
||||
- name: Build UI Image
|
||||
run: ./build_image.sh rootfs
|
19
Dockerfile
19
Dockerfile
@ -1,11 +1,9 @@
|
||||
# Builder
|
||||
FROM docker.io/library/node:slim AS builder
|
||||
# Base Env
|
||||
FROM docker.io/library/node:slim AS base
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
git \
|
||||
gnupg \
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates curl git gnupg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
@ -13,11 +11,16 @@ ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
WORKDIR /builder
|
||||
|
||||
# Builder
|
||||
FROM base AS builder
|
||||
|
||||
COPY package.json /builder/package.json
|
||||
COPY pnpm-lock.yaml /builder/pnpm-lock.yaml
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
COPY . /builder
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm run build
|
||||
|
||||
# Main
|
||||
|
@ -1,10 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COLOR_RED="\e[0;31m"
|
||||
COLOR_GREEN="\e[0;32m"
|
||||
COLOR_NONE="\e[0m"
|
||||
|
||||
function log_info() { echo -e "${COLOR_GREEN}$*${COLOR_NONE}" 1>&2; }
|
||||
function log_error() { echo -e "${COLOR_RED}$*${COLOR_NONE}" 1>&2; }
|
||||
|
||||
DOCKER="${DOCKER:-podman}"
|
||||
VERSION=$(jq -r .version < package.json)
|
||||
IMAGE_PREFIX=${IMAGE_PREFIX:-"git.0x7f.app/woj"}
|
||||
|
||||
set -x
|
||||
if [ -f ".env.sentry-build-plugin" ]; then source .env.sentry-build-plugin; fi
|
||||
if [ -z "$SENTRY_AUTH_TOKEN" ]; then log_error "SENTRY_AUTH_TOKEN not found!"; exit 1; fi
|
||||
|
||||
$DOCKER build -t "${IMAGE_PREFIX}/woj-ui:${VERSION}" .
|
||||
$DOCKER push "${IMAGE_PREFIX}/woj-ui:${VERSION}"
|
||||
log_info "=== Configuration ==="
|
||||
log_info "DOCKER: ${DOCKER}"
|
||||
log_info "IMAGE: ${IMAGE_PREFIX}/woj-ui:${VERSION}"
|
||||
log_info "SENTRY_AUTH_TOKEN: $(echo "$SENTRY_AUTH_TOKEN" | head -c 12)***"
|
||||
|
||||
log_info "=== Build ==="
|
||||
$DOCKER build -t "${IMAGE_PREFIX}/woj-ui:${VERSION}" --env "SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}" . || { log_error "Build image failed!"; exit 1; }
|
||||
|
||||
log_info "=== Push ==="
|
||||
$DOCKER push "${IMAGE_PREFIX}/woj-ui:${VERSION}" || { log_error "Push image failed"; exit 1; }
|
||||
|
Loading…
Reference in New Issue
Block a user