Skip to content

Commit

Permalink
Merge pull request #23 from mizunashi-mana/make-deb-source
Browse files Browse the repository at this point in the history
Make deb source
  • Loading branch information
mizunashi-mana committed May 4, 2024
2 parents 41f8c7c + 1c0f2c9 commit d4ad887
Show file tree
Hide file tree
Showing 59 changed files with 340 additions and 304 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ jobs:
strategy:
matrix:
include:
- distro_base: "debian"
distro: "bookworm"
arch: amd64
- distro_base: "ubuntu"
distro: "jammy"
distro: "noble"
arch: amd64
- distro_base: "debian"
distro: "bullseye"
distro: "bookworm"
arch: amd64
- distro_base: "ubuntu"
distro: "focal"
distro: "jammy"
arch: amd64

steps:
Expand All @@ -33,7 +30,7 @@ jobs:
- name: Check package version
if: startsWith(github.ref, 'refs/tags/')
run: |
env TRACE=true ./scripts/check-version "$GITHUB_REF_NAME"
env TRACE=true ./tests/check-version "$GITHUB_REF_NAME"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -49,20 +46,20 @@ jobs:
- name: Build deb
uses: docker/build-push-action@v5
with:
file: ./deb/Dockerfile
file: ./Dockerfile
load: true
target: debcontainer
build-args: |
DISTRO_BASE=${{ matrix.distro_base }}
DISTRO=${{ matrix.distro }}
platforms: ${{ steps.docker_setup_buildx.outputs.platforms }}
tags: ghcr.io/mizunashi-mana/firefish-dist-pkg/debian-debcontainer
tags: ghcr.io/mizunashi-mana/firefish-dist-pkg/debcontainer
cache-from: type=gha
cache-to: type=gha

- name: Copy deb
run: |
docker create --name deb ghcr.io/mizunashi-mana/firefish-dist-pkg/debian-debcontainer
docker create --name deb ghcr.io/mizunashi-mana/firefish-dist-pkg/debcontainer
docker cp deb:/workdir/dest ./dest
docker rm deb
for file in $(find ./dest -type f); do
Expand All @@ -74,7 +71,7 @@ jobs:
- name: Test deb version
if: startsWith(github.ref, 'refs/tags/')
run: |
env TRACE=true ./deb/scripts/test-version "$GITHUB_REF_NAME" ./dest/*.deb
env TRACE=true ./tests/test-version "$GITHUB_REF_NAME" ./dest/*.deb
- name: Archive deb artifact
uses: actions/upload-artifact@v3
Expand All @@ -83,11 +80,13 @@ jobs:
retention-days: 1
path: |
./dest/*.deb
./dest/*.changes
./dest/*.buildinfo
./dest/*.debian.tar.*
- name: Build compose images
uses: docker/bake-action@v4
with:
workdir: ./deb
files: ./docker-compose.yml
load: true
set: |
Expand All @@ -99,16 +98,15 @@ jobs:
- name: Pull compose images
run: |
docker compose --file deb/docker-compose.yml \
pull postgres redis
docker compose --file docker-compose.yml pull \
postgres redis
- name: Up services and test
run: |
docker compose --file deb/docker-compose.yml \
docker compose --file docker-compose.yml \
up --detach
sleep 10
env TRACE=true ./deb/scripts/test-service
docker compose --file deb/docker-compose.yml logs
env TRACE=true ./tests/test-service
docker compose --file docker-compose.yml logs
release:
needs:
Expand Down Expand Up @@ -141,3 +139,6 @@ jobs:
with:
files: |
*.deb
*.changes
*.buildinfo
*.debian.tar.*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/tmp/
/pkg/
/dest/

# build
.stamp.*
32 changes: 20 additions & 12 deletions deb/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,32 @@ SHELL ["bash", "-euxo", "pipefail", "-c"]
ARG DISTRO

ENV WORK_DIR=/workdir
ENV DEBIAN_FRONTEND=noninteractive

FROM base AS builder

WORKDIR "${WORK_DIR}"

COPY deb/scripts "${WORK_DIR}/scripts"
COPY common "${WORK_DIR}/common"
COPY deb/files "${WORK_DIR}/files"
COPY deb/Makefile "${WORK_DIR}/Makefile"
COPY scripts "${WORK_DIR}/scripts"
COPY configs "${WORK_DIR}/configs"
COPY debian/files "${WORK_DIR}/debian/files"
COPY Makefile "${WORK_DIR}/Makefile"
COPY envs "${WORK_DIR}/envs"

RUN <<EOT
scripts/install-build-deps

source "$HOME/.cargo/env"
make firefish.deb
make

apt-get remove -y \
wget \
dh-make \
git \
make \
rsync \
nodejs
nodejs \
build-essential \

apt-get autoremove -y
apt-get clean
rm -rf \
Expand All @@ -40,23 +43,26 @@ rm -rf \
~/.cache \
~/.cargo \
~/.rustup \
pkg/firefish-*/packages/backend-rs/target \
pkg/firefish-*/* \
/var/lib/apt/lists/*
EOT

FROM base AS debcontainer

COPY --from=builder "${WORK_DIR}/firefish.deb" "${WORK_DIR}/dest/firefish.deb"
COPY --from=builder "${WORK_DIR}/pkg/*.deb" "${WORK_DIR}/dest/"
COPY --from=builder "${WORK_DIR}/pkg/*.changes" "${WORK_DIR}/dest/"
COPY --from=builder "${WORK_DIR}/pkg/*.buildinfo" "${WORK_DIR}/dest/"
COPY --from=builder "${WORK_DIR}/pkg/*.debian.tar.*" "${WORK_DIR}/dest/"

FROM base AS runner

COPY --from=debcontainer "${WORK_DIR}/dest" "${WORK_DIR}/dest"
COPY --from=debcontainer "${WORK_DIR}/dest/*.deb" "${WORK_DIR}/dest/"

COPY deb/scripts/install-deb "${WORK_DIR}/scripts/install-deb"
COPY scripts/install-deb "${WORK_DIR}/scripts/install-deb"
RUN <<EOT
env \
TRACE=true \
"DEB_FILE=${WORK_DIR}/dest/firefish.deb" \
"DEB_FILE=$(find "${WORK_DIR}/dest/" -name '*.deb')" \
"${WORK_DIR}/scripts/install-deb"

apt-get clean
Expand All @@ -67,8 +73,10 @@ rm -rf \
EOT

USER firefish

WORKDIR /var/lib/firefish/live/packages/backend

ENV NODE_ENV=production
ENV RUN_MIGRATION_ON_START=true
ENV TRACE=true

Expand Down
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/make -f

include envs/common.make

PKG_VERSION_DEB_MAIN=$(subst -,+,$(PKG_VERSION_FIREFISH))

SOURCE_TARBALL=pkg/firefish_$(PKG_VERSION_DEB_MAIN).orig.tar.gz
PKG_FILES_DIR=pkg/firefish-$(PKG_VERSION_DEB_MAIN)

.PHONY: all
all: deb

.PHONY: source
source:
env \
'SOURCE_GIT_REPOSITORY=$(FIREFISH_SOURCE_GIT_REPO)' \
'SOURCE_GIT_REVISION=$(FIREFISH_SOURCE_GIT_COMMIT_REF)' \
./scripts/create-orig-files '$(SOURCE_TARBALL)'

.PHONY: pkg-files
pkg-files: source
rm -rf '$(PKG_FILES_DIR)'
./scripts/create-pkg-files '$(PKG_FILES_DIR)' '$(SOURCE_TARBALL)'

.PHONY: deb
deb: pkg-files
./scripts/build-deb '$(PKG_FILES_DIR)'
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
# Distribution Packages of Firefish
# Debian Package Repository of Firefish

Free to install dev dependencies, build with Rust and use pm2. Run by systemd with security sandbox.

## Debian / Ubuntu
## How to Use

Currently, supports amd64 (x86_64) architecture only.
WIP

How to run:
## How to Build Package

1. Install nodejs v20: https://github.com/nodesource/distributions#debinstall
2. Download deb from https://github.com/mizunashi-mana/firefish-dist-pkg/releases.
3. Install deb by `apt install ./*_firefish.deb`.
4. Edit `/etc/firefish/config.yml` and restart firefish by `systemctl restart firefish`.
```
docker build \
--target debcontainer \
--tag ghcr.io/mizunashi-mana/firefish-dist-pkg/debcontainer \
.
docker create --name deb ghcr.io/mizunashi-mana/firefish-dist-pkg/debcontainer
docker cp deb:/workdir/dest ./dest
docker rm deb
```

## How to Build Repository

WIP

## License Notice

Expand Down
8 changes: 0 additions & 8 deletions common/env/env.make

This file was deleted.

30 changes: 0 additions & 30 deletions common/tasks/build

This file was deleted.

5 changes: 5 additions & 0 deletions configs/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor/cargo"
2 changes: 2 additions & 0 deletions configs/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cache = vendor/npm
store-dir = vendor/pnpm
11 changes: 11 additions & 0 deletions configs/about.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
accepted = [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"ISC",
"MIT",
"MPL-2.0",
"NOASSERTION",
"OpenSSL",
"Unicode-DFS-2016",
]
4 changes: 0 additions & 4 deletions deb/.gitignore

This file was deleted.

39 changes: 0 additions & 39 deletions deb/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion deb/common

This file was deleted.

20 changes: 0 additions & 20 deletions deb/docker/postgres-setup/Dockerfile

This file was deleted.

0 comments on commit d4ad887

Please sign in to comment.