Skip to content

Commit

Permalink
chore(docker): publish docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed Feb 4, 2024
1 parent 3e446f0 commit f091766
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish Docker Image

on:
push:

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

env:
IMAGE_NAME: commune
GHCR_REGISTRY: ghcr.io/commune-os
OPENSSL_LIB_DIR: "/usr/lib/x86_64-linux-gnu"
OPENSSL_INCLUDE_DIR: "/usr/include/openssl"

jobs:
publish_image:
name: Publish image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-unknown-linux-musl

- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2

- name: Setup Rust Target
run: rustup target add x86_64-unknown-linux-musl

- name: Install Build Dependencies
run: |
sudo apt-get install librust-openssl-dev \
libssl-dev
- name: Setup Zig
uses: goto-bus-stop/[email protected]

- name: Install ZigBuild
run: cargo install cargo-zigbuild

- name: Install Just
uses: extractions/setup-just@v1

- name: Build Image
run: just docker_build_image
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG ARCH=

FROM ${ARCH}alpine:3

COPY server /opt/commune

WORKDIR app

ENTRYPOINT ["/opt/commune"]
14 changes: 14 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set positional-arguments

commit_sha := `git rev-parse --verify HEAD`
target_release := "x86_64-unknown-linux-musl"

# Lists all available commands
default:
just --list
Expand Down Expand Up @@ -60,3 +63,14 @@ clear: stop
# Runs all the tests from the `test` package. Optionally runs a single one if name pattern is provided
e2e *args='':
cargo test --package test -- --nocapture --test-threads=1 $1

# Builds the Server binary used in the Docker Image
docker_build_server:
cargo zigbuild --target {{target_release}} --release -p server

# Builds the Docker image for the backend
docker_build_image: docker_build_server
mkdir tmp/
cp ./target/{{target_release}}/release/server ./tmp/server
chmod +x ./tmp/server
docker build -t "commune:{{commit_sha}}-{{target_release}}" --build-arg ARCH=arm64v8/ .

0 comments on commit f091766

Please sign in to comment.