Skip to content

Commit

Permalink
feat: initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Aug 12, 2024
1 parent d0bd5ce commit 24dceef
Show file tree
Hide file tree
Showing 19 changed files with 1,087 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!bin
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
21 changes: 21 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>containerbase/.github",
"github>containerbase/.github//merge-queue.json"
],
"packageRules": [
{
"description": "Enable minor updates on renovate rebuild trigger file",
"matchFiles": ["renovate.Dockerfile"],
"matchUpdateTypes": ["minor"],
"enabled": true
},
{
"description": "extract wally version",
"matchPackageNames": ["UpliftGames/wally"],
"matchDatasources": ["github-releases"],
"extractVersion": "v(?<version>.+)"
}
]
}
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: build

on:
push:
branches:
- main

pull_request:

merge_group:

schedule:
- cron: '0 1 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

env:
HUSKY: 0

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: ⚙️ Setup pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
standalone: true

- name: ⚙️ Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: 'pnpm'

- run: pnpm install
- run: pnpm prettier

build:
needs:
- lint
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
distro:
- focal
# - jammy
arch:
- x86_64
# - aarch64

env:
DISTRO: ${{ matrix.distro }} # build target, name required by binary-builder
ARCH: ${{ matrix.arch }} # build target, name required by binary-builder

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: binary-builder
uses: containerbase/internal-tools@c30fd9e43f9adb66114fcf23bd74bf4179b158a1 # v3.4.3
with:
command: binary-builder
dry-run: ${{github.ref != 'refs/heads/main'}}
token: ${{ secrets.GITHUB_TOKEN }}
last-only: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
/.pnpm-store/

/.cache/
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*": "prettier --ignore-unknown --write"
}
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.16.0
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
save-exact = true
save-prefix =

# pnpm run settings
# https://pnpm.io/cli/run
shell-emulator = true
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
/coverage/
/dist/
/bin/
/tmp/
/html/
/.cache/


# pnpm
pnpm-lock.yaml
/.pnpm-store
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",
"plugins": ["prettier-plugin-packagejson"]
}
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

#--------------------------------------
# Ubuntu flavor
#--------------------------------------
ARG DISTRO=focal

#--------------------------------------
# base images
#--------------------------------------
FROM ghcr.io/containerbase/ubuntu:20.04@sha256:0b897358ff6624825fb50d20ffb605ab0eaea77ced0adb8c6a4b756513dec6fc AS build-focal
FROM ghcr.io/containerbase/ubuntu:22.04@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221 AS build-jammy

#--------------------------------------
# containerbase image
#--------------------------------------
FROM ghcr.io/containerbase/base:11.9.1@sha256:abc869b6fd4bffbf0ccd107ffc73078bd3e6aeb2ff08858424cdd5810ee920e6 AS containerbase

FROM build-${DISTRO}

# Allows custom apt proxy usage
ARG APT_HTTP_PROXY

# Set env and shell
ENV BASH_ENV=/usr/local/etc/env ENV=/usr/local/etc/env
SHELL ["/bin/bash" , "-c"]

# Set up containerbase
COPY --from=containerbase /usr/local/sbin/ /usr/local/sbin/
COPY --from=containerbase /usr/local/containerbase/ /usr/local/containerbase/
RUN install-containerbase


# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.30.0

# renovate: datasource=docker versioning=docker
RUN install-tool rust 1.79.0

ENTRYPOINT [ "dumb-init", "--", "builder.sh" ]

COPY --chmod=755 bin /usr/local/bin

ENV TOOL_NAME=wally

RUN install-builder.sh

WORKDIR /usr/src/wally

ENV OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu OPENSSL_INCLUDE_DIR=/usr/include/openssl

RUN builder.sh 0.3.2
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# wally
Prebuild Wally for containerbase
# containerbase Wally releases

[![build](https://github.com/containerbase/wally-prebuild/actions/workflows/build.yml/badge.svg)](https://github.com/containerbase/wally-prebuild/actions/workflows/build.yml?query=branch%3Amain)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/containerbase/wally-prebuild)
![License: MIT](https://img.shields.io/github/license/containerbase/wally-prebuild)

Prebuild Wally releases used by [containerbase/base](https://github.com/containerbase/base).

## Local development

Build the image

```bash
docker build -t builder --build-arg APT_HTTP_PROXY=http://apt-proxy:3142 --build-arg DISTRO=focal .
```

Test the image

```bash
docker run --rm -it -v ${PWD}/.cache:/cache -e DEBURG=true builder 0.3.2
```

`${PWD}/.cache` will contain packed releases after successful build.

Optional environment variables

| Name | Description | Default |
| ---------------- | ------------------------------------------------------------ | --------- |
| `DISTRO` | Set an ubuntu base distro, `focal` and `jammy` are supported | `focal` |
| `APT_HTTP_PROXY` | Set an APT http proxy for installing build deps | `<empty>` |
| `DEBUG` | Show verbose php build output | `<empty>` |
50 changes: 50 additions & 0 deletions bin/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -e

# shellcheck source=/dev/null
. /usr/local/containerbase/util.sh
# shellcheck source=/dev/null
. /usr/local/containerbase/utils/v2/overrides.sh

# trim leading v
TOOL_VERSION=${1#v}

# shellcheck disable=SC1091
CODENAME=$(. /etc/os-release && echo "${VERSION_CODENAME}")

ARCH=$(uname -p)
tp=$(create_versioned_tool_path)

check_semver "${TOOL_VERSION}"

echo "Building ${TOOL_NAME} ${TOOL_VERSION} for ${CODENAME}-${ARCH}"

if [[ "${DEBUG}" == "true" ]]; then
set -x
fi

echo "------------------------"
echo "init repo"
git reset --hard "v${TOOL_VERSION}"


echo "------------------------"
echo "build ${TOOL_NAME}"
cargo build --locked --release --bin wally

mkdir "${tp}/bin"
cp target/release/wally "${tp}/bin/wally"
shell_wrapper wally "${tp}/bin"

echo "------------------------"
echo "testing"
wally --version

file "${tp}/bin/wally"
ldd "${tp}/bin/wally"

echo "------------------------"
echo "create archive"
echo "Compressing ${TOOL_NAME} ${TOOL_VERSION} for ${CODENAME}-${ARCH}"
tar -cJf "/cache/${TOOL_NAME}-${TOOL_VERSION}-${CODENAME}-${ARCH}.tar.xz" -C "$(find_tool_path)" "${TOOL_VERSION}"
23 changes: 23 additions & 0 deletions bin/install-builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

# shellcheck source=/dev/null
. /usr/local/containerbase/util.sh
# shellcheck source=/dev/null
. /usr/local/containerbase/utils/v2/overrides.sh

# add required system packages
install-apt \
build-essential \
file \
libssl-dev \
pkg-config \
;

# prepare nix source
git clone https://github.com/UpliftGames/wally.git /usr/src/wally

# create folders
create_tool_path > /dev/null
mkdir /cache
10 changes: 10 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"image": "wally",
"depName": "UpliftGames/wally",
"datasource": "github-releases",
"versioning": "semver",
"extractVersion": "v(?<version>.+)",
"startVersion": "0.3.0",
"ignoredVersions": [],
"reverse": true
}
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "containerbase-wally-prebuild",
"private": true,
"repository": "https://github.com/containerbase/wally-prebuild.git",
"license": "MIT",
"author": "Michael Kriese <michael.kriese@visualon.de>",
"scripts": {
"lint": "run-s prettier",
"prepare": "husky",
"prettier": "prettier --cache -c -u '**/*.*'",
"prettier-fix": "prettier --cache -w -u '**/*.*'"
},
"devDependencies": {
"husky": "9.1.4",
"lint-staged": "15.2.8",
"npm-run-all2": "6.2.2",
"prettier": "3.3.3",
"prettier-plugin-packagejson": "2.5.1"
},
"packageManager": "pnpm@9.7.0",
"engines": {
"node": ">=20.9.0",
"pnpm": "^9.0.0"
}
}
Loading

0 comments on commit 24dceef

Please sign in to comment.