Skip to content

Commit

Permalink
- Improve binary compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
LetrixZ committed Dec 25, 2024
1 parent 7ab8dc1 commit cf722ff
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 27 deletions.
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.svelte-kit
build
node_modules
node_modules
*.sqlite*
faccina*
.gitignore
docker/*
*.sh
!build.sh
compile
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,4 @@ config.toml
docker-compose.yaml

compile
faccina
faccina.tar.gz
faccina.zip
faccina*
20 changes: 0 additions & 20 deletions app/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
import type { Handle } from '@sveltejs/kit';
import chalk from 'chalk';
import dedent from 'dedent';
import { building } from '$app/environment';
import { lucia } from '$lib/server/auth';
import { log } from '$lib/server/utils';
import config from '~shared/config';

if (!building) {
const glob = new Bun.Glob('*/{cover,thumbnail}');
const { done } = glob.scanSync({ cwd: config.directories.images, onlyFiles: false }).next();

if (!done) {
console.log(
chalk.cyan(
dedent(`
${chalk.yellow.bold(`IMPORTANT UPDATE!`)}
Generated images are now stored in a folder with its name generated by hashing the encoder properties.
This change was made to facilitate changing preset encoding options without needing to delete old generated images.
You have generated images stored with the old naming format.
Run the ${chalk.bold('migrate:preset-hash')} command to migrate these to the new naming format.`)
)
);
}
}

export const handle: Handle = async ({ event, resolve }) => {
const start = performance.now();
const sessionId = event.cookies.get(lucia().sessionCookieName);
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bun install && bun run build && \
rm -rf compile && mkdir compile && \
bun install && bun run build &&
rm -rf compile && mkdir compile &&
bunx make-vfs --dir ./build/client --content-format import-bunfile --outfile compile/client-routes.ts &&
bun ./embed-sharp.ts &&
bun build --outfile faccina --minify --sourcemap --compile ./entrypoint.ts
3 changes: 3 additions & 0 deletions cli/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import chalk from 'chalk';
import { Argument, Command, Option } from 'commander';
import { version } from '../package.json';
import * as archive from './archive';
import * as images from './images';
import * as metadataCli from './metadata-cli';
Expand All @@ -8,6 +9,8 @@ import * as users from './users';

const program = new Command();

program.version(version);

program
.command('index')
.option('-p --paths <paths...>', 'Index given paths.')
Expand Down
4 changes: 4 additions & 0 deletions dist-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
docker buildx build --platform=linux/amd64,linux/arm64 -f ./docker/Dockerfile-compile-linux -o compile . &&
mv compile/linux_amd64/faccina faccina-linux-amd64 &&
mv compile/linux_arm64/faccina faccina-linux-arm64
29 changes: 29 additions & 0 deletions docker/Dockerfile-compile-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:focal AS build
WORKDIR /build
ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get -y --no-install-recommends install \
unzip curl build-essential ninja-build python3-pip bc wget libfftw3-dev libopenexr-dev libgsf-1-dev libglib2.0-dev liborc-dev libopenslide-dev libmatio-dev libwebp-dev libjpeg-turbo8-dev libexpat1-dev libexif-dev libtiff5-dev libcfitsio-dev libpoppler-glib-dev librsvg2-dev libpango1.0-dev libopenjp2-7-dev liblcms2-dev libimagequant-dev
RUN pip3 install meson
RUN wget https://github.com/libvips/libvips/archive/refs/heads/master.zip && unzip master.zip
WORKDIR /build/libvips-master
RUN meson setup build --libdir=lib --buildtype=release --wipe
RUN cd build && meson compile && meson install
RUN ldconfig

WORKDIR /app
RUN curl -fsSL https://bun.sh/install | bash
COPY package.json bun.lockb ./
COPY patches ./patches
RUN --mount=target=/root/.bun/install/cache,type=cache \
PATH="/root/.bun/bin:$PATH" SHARP_FORCE_GLOBAL_LIBVIPS=1 bun install --frozen-lockfile --verbose

COPY . .
RUN PATH="/root/.bun/bin:$PATH" ./build.sh

FROM scratch
COPY --from=build /app/faccina /faccina
ENTRYPOINT [ "/faccina" ]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "faccina",
"version": "2.0.0-alpha.51",
"version": "2.0.0-beta",
"private": true,
"scripts": {
"prepare": "svelte-kit sync",
Expand Down

0 comments on commit cf722ff

Please # to comment.