Skip to content

Commit

Permalink
Add Katbin as a submodule and integrate into package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwen committed Aug 23, 2024
1 parent 6f11d6a commit 8d20fe3
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/katbin-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Push Katbin Docker Image

on:
push:
branches: [ main ]
paths:
- 'katbin/**'
- '.github/workflows/katbin-build-push.yml'
pull_request:
branches: [ main ]
paths:
- 'katbin/**'
- '.github/workflows/katbin-build-push.yml'
workflow_dispatch: # Allow manual triggering

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./katbin
file: ./katbin/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/katbin:latest
ghcr.io/${{ github.repository_owner }}/katbin:${{ github.sha }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "katbin/source"]
path = katbin/source
url = https://github.com/SphericalKat/katbin
54 changes: 54 additions & 0 deletions katbin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM elixir:alpine AS build

# install build dependencies
RUN apk add --no-cache build-base npm git curl py-pip rust cargo

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force

# set build ENV
ENV MIX_ENV=prod

# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile

# build assets
COPY assets/package.json assets/package-lock.json ./assets/
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error

COPY priv priv
COPY assets assets
COPY lib lib
COPY native native
RUN npm run --prefix ./assets deploy
RUN mix phx.digest

# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release

# prepare release image
FROM alpine AS app
RUN apk add --no-cache openssl ncurses-libs libstdc++

WORKDIR /app

RUN chown nobody:nobody /app

USER nobody:nobody

COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/ketbin ./

COPY --chown=nobody:nobody startup.sh startup.sh

RUN chmod +x /app/startup.sh

ENV HOME=/app

CMD ["/app/startup.sh"]
25 changes: 25 additions & 0 deletions katbin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Katbin

This directory contains the configuration for Katbin, a pastebin service written in Kotlin, as part of the versatile package manager.

## Features

- Pastebin functionality
- Written in Kotlin
- Containerized for easy deployment

## Files

- `Dockerfile`: Defines the Katbin build and runtime environment
- `source/`: Git submodule containing the Katbin source code

## Usage

1. Ensure you've initialized and updated the git submodule:
```
git submodule update --init --recursive
```
2. Build the Docker image using the provided Dockerfile
3. Run the container, exposing port 8080

For more details on Katbin, please refer to the original project: [https://github.com/sphericalkat/katbin](https://github.com/sphericalkat/katbin)
1 change: 1 addition & 0 deletions katbin/source
Submodule source added at ebd9f7

0 comments on commit 8d20fe3

Please sign in to comment.