Skip to content

Commit

Permalink
chore: add github actions workflow, add land-server and land-worker d…
Browse files Browse the repository at this point in the history
…ockerfiles
  • Loading branch information
fuxiaohei committed Nov 26, 2024
1 parent 0a0ba42 commit 70eeb03
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
.vscode/
assets/
data/
demo/
49 changes: 49 additions & 0 deletions .github/workflows/ghcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build Github Packages
on:
push:
branches:
- main
- dev
tags: ["v*"]
env:
CARGO_TERM_COLOR: always
concurrency:
group: ghcr-${{ github.ref }}
cancel-in-progress: true

jobs:
dockerize:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./land-worker.Dockerfile
image: ghcr.io/${{ github.repository_owner }}/runtime-land-worker
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ matrix.image }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Container Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions land-server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust:1.82 AS build

WORKDIR /usr/src/land-server
COPY . .
RUN rustup component add rustfmt
RUN bash /usr/src/land-server/scripts/land-server-deps.sh
RUN cargo version
RUN cargo build -p land-server --release

FROM debian:stable-slim
WORKDIR /opt/bin/
RUN \
apt-get update && \
apt-get install -y ca-certificates && \
apt-get clean
COPY --from=build /usr/src/land-server/target/release/land-server /opt/bin/land-server
COPY --from=build /usr/src/land-server/wizer-v6.0.0-x86_64-linux /opt/bin/wizer
EXPOSE 9840
CMD ["/opt/bin/land-server","--verbose"]
13 changes: 13 additions & 0 deletions land-worker.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1.82 as build

WORKDIR /usr/src/land-src
COPY . .
RUN rustup component add rustfmt
RUN cargo version
RUN cargo build -p land-worker --release

FROM debian:stable-slim
WORKDIR /opt/bin/
COPY --from=build /usr/src/land-src/target/release/land-worker /opt/bin/land-worker
EXPOSE 9940
CMD ["/opt/bin/land-worker","--verbose"]
42 changes: 42 additions & 0 deletions scripts/land-server-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Print in colors - 1=green, 2=red, other=neutral
# e.g. log_print 0 "All is great"
log_print() {
if [[ $1 == 1 ]]; then
echo -e "${GREEN}${2}${NC}"
elif [[ $1 == 2 ]]; then
echo -e "${RED}${2}${NC}"
else
echo -e "${2}"
fi
}

set -e
set -o pipefail

# Function used to check if utilities are available
require() {
if ! hash "$1" &>/dev/null; then
log_print 2 "'$1' not found in PATH. This is required for this script to work."
exit 1
fi
}

require curl
require tar

download_wizer_binary() {
log_print 0 "Downloading wizer"
local archive_url="https://github.com/bytecodealliance/wizer/releases/download/v7.0.5/wizer-v7.0.5-x86_64-linux.tar.xz"
log_print 1 "Downloading wizer: $archive_url"
curl --progress-bar --show-error --location --fail $archive_url --output "wizer-v7.0.5.tar.xz"
tar -xvf "wizer-v7.0.5.tar.xz"
}

download_wizer_binary

0 comments on commit 70eeb03

Please sign in to comment.