-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Katbin as a submodule and integrate into package manager
- Loading branch information
liuwen
committed
Aug 23, 2024
1 parent
6f11d6a
commit 8d20fe3
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |