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

WIP: Build server inside Dockerfile #1488

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 21 additions & 32 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Free up disk space
if: ${{ inputs.build_multiarch }}
shell: bash
Expand All @@ -33,7 +32,7 @@ jobs:
# ======
# MACROS
# ======

# macro to print a line of equals
# (silly but works)
printSeparationLine() {
Expand All @@ -48,21 +47,21 @@ jobs:
done
echo "${output}"
}

# macro to compute available space
# REF: https://unix.stackexchange.com/a/42049/60849
# REF: https://stackoverflow.com/a/450821/408734
getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); }

# macro to make Kb human readable (assume the input is Kb)
# REF: https://unix.stackexchange.com/a/44087/60849
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }

# macro to output saved space
printSavedSpace() {
saved=${1}
title=${2:-}

echo ""
printSeparationLine '*' 80
if [ ! -z "${title}" ]; then
Expand All @@ -73,11 +72,11 @@ jobs:
printSeparationLine '*' 80
echo ""
}

# macro to print output of dh with caption
printDH() {
caption=${1:-}

printSeparationLine '=' 80
echo "${caption}"
echo ""
Expand All @@ -96,15 +95,15 @@ jobs:
# ======
# SCRIPT
# ======

# Display initial disk space stats

AVAILABLE_INITIAL=$(getAvailableSpace)
AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/')

printDH "BEFORE CLEAN-UP:"
echo ""

# Remove Android library
BEFORE=$(getAvailableSpace)

Expand All @@ -113,7 +112,7 @@ jobs:
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Android library"

BEFORE=$(getAvailableSpace)

# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
Expand All @@ -122,18 +121,18 @@ jobs:
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED ".NET runtime"

BEFORE=$(getAvailableSpace)

sudo rm -rf /opt/ghc

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Haskell runtime"

# Remove large packages
# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh

BEFORE=$(getAvailableSpace)

sudo apt-get remove -y '^aspnetcore-.*'
Expand All @@ -149,7 +148,7 @@ jobs:
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Large misc. packages"

# Remove Docker images
BEFORE=$(getAvailableSpace)

Expand All @@ -169,18 +168,18 @@ jobs:
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Swap storage"

# Output saved space statistic

AVAILABLE_END=$(getAvailableSpace)
AVAILABLE_ROOT_END=$(getAvailableSpace '/')

echo ""
printDH "AFTER CLEAN-UP:"

echo ""
echo ""

echo "/dev/root:"
printSavedSpace $((AVAILABLE_ROOT_END - AVAILABLE_ROOT_INITIAL))
echo "overall:"
Expand All @@ -189,15 +188,6 @@ jobs:
- name: Install GraphViz
run: sudo apt-get install graphviz -y

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin

- name: Build Java server
run: make buildServer

- name: Set up QEMU
if: ${{ inputs.build_multiarch }}
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -243,4 +233,3 @@ jobs:
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

18 changes: 0 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install GraphViz
run: sudo apt-get install graphviz -y
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- name: Build Java server
run: make buildServer
- run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Generate checksums
run: |
Expand All @@ -36,15 +27,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install GraphViz
run: sudo apt-get install graphviz -y
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- name: Build Java server
run: make buildServer
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand Down
1 change: 1 addition & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target "kroki" {
wavedrom = "./wavedrom"
bytefield = "./bytefield"
tikz = "./tikz"
kroki-src = "."
}
dockerfile = "ops/docker/jdk11-jammy/Dockerfile"
tags = ["yuzutech/kroki:${TAG}"]
Expand Down
12 changes: 11 additions & 1 deletion server/ops/docker/jdk11-jammy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# syntax=docker/dockerfile:1.4

## Kroki server
FROM maven:3.9.3-eclipse-temurin-11 as kroki-builder-server
COPY --from=kroki-src . /kroki
WORKDIR /kroki
RUN apt-get update \
&& apt-get install graphviz -y \
&& apt-get clean \
&& apt-get autoremove
RUN mvn --no-transfer-progress clean package

## TikZ
FROM --platform=$BUILDPLATFORM ubuntu:jammy AS kroki-builder-dvisvgm

Expand Down Expand Up @@ -332,7 +342,7 @@ ENV KROKI_SYMBOLATOR_BIN_PATH=/usr/bin/symbolator
ENV KROKI_BLOCKDIAG_BIN_PATH=/usr/bin/blockdiag
ENV JAVA_OPTS="-Dlogback.configurationFile=/etc/kroki/logback.xml -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory"

COPY --chown=kroki:kroki target/kroki-server.jar /usr/local/kroki/kroki-server.jar
COPY --from=kroki-builder-server --chown=kroki:kroki /kroki/server/target/kroki-server.jar /usr/local/kroki/kroki-server.jar

EXPOSE 8000

Expand Down
3 changes: 3 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
</configuration>
<version>4.9.10</version>
<executions>
<execution>
Expand Down