Skip to content

Commit

Permalink
remove nix, use standard docker build and use pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 6, 2023
1 parent 37099d3 commit 27e7595
Show file tree
Hide file tree
Showing 27 changed files with 3,720 additions and 7,488 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.git
.gitignore
*.md
dist
build
data
.env
.github
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

4 changes: 0 additions & 4 deletions .fleet/settings.json

This file was deleted.

40 changes: 32 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,39 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache install Nix packages
uses: mtoohey31/cache-flake-attrs@v2
- name: OCI meta
id: meta
uses: docker/metadata-action@v5
with:
key: ${{ runner.os }}-nix-${{ hashFiles('./flake.lock', './flake.nix', './yarn.lock') }}
flake_paths: .#packages.x86_64-linux.docker.copyTo
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Build and push
run: |
nix --extra-experimental-features nix-command --extra-experimental-features flakes run .#docker.copyTo -vL -- --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} docker://ghcr.io/${GITHUB_REPOSITORY,,}:${{ github.sha }}
nix --extra-experimental-features nix-command --extra-experimental-features flakes run .#docker.copyTo -vL -- --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} docker://ghcr.io/${GITHUB_REPOSITORY,,}:${{ github.ref_name }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max
363 changes: 0 additions & 363 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

1 change: 0 additions & 1 deletion .yarn/plugins/yarn-plugin-nixify.cjs

This file was deleted.

768 changes: 0 additions & 768 deletions .yarn/releases/yarn-3.1.1.cjs

This file was deleted.

11 changes: 0 additions & 11 deletions .yarnrc.yml

This file was deleted.

60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# syntax=docker/dockerfile:labs

FROM node:18-slim AS base
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get --no-install-recommends install -y \
fonts-wqy-microhei \
libpixman-1-0 libcairo2 libpango1.0-0 libgif7 libjpeg62-turbo libpng16-16 librsvg2-2 libvips42 ffmpeg librlottie0-1
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app

FROM base AS build-env
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get --no-install-recommends install -y \
python3 build-essential pkg-config \
libpixman-1-dev libcairo2-dev libpango1.0-dev libgif-dev libjpeg62-turbo-dev libpng-dev librsvg2-dev libvips-dev
COPY package.json pnpm-lock.yaml /app/

FROM build-env AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM build-env AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY src tsconfig.json /app/
COPY prisma /app/
RUN pnpm exec prisma generate
RUN pnpm run build

FROM debian:bookworm-slim AS tgs-to-gif-build
ADD https://github.com/conan-io/conan/releases/download/1.61.0/conan-ubuntu-64.deb /tmp/conan.deb
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get --no-install-recommends install -y \
python3 build-essential pkg-config cmake librlottie-dev zlib1g-dev /tmp/conan.deb

ADD https://github.com/ed-asriyan/lottie-converter.git#f626548ced4492235b535552e2449be004a3a435 /app
WORKDIR /app
RUN sed -i 's@zlib/1.2.11@@g' conanfile.txt
RUN conan install .
RUN sed -i 's/\${CONAN_LIBS}/z/g' CMakeLists.txt
RUN cmake CMakeLists.txt && make

FROM base
COPY assets /app/

COPY --from=tgs-to-gif-build /app/bin/tgs_to_gif /usr/local/bin/tgs_to_gif
ENV TGS_TO_GIF=/usr/local/bin/tgs_to_gif

COPY package.json pnpm-lock.yaml /app/
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY prisma /app/
RUN pnpm exec prisma generate
COPY --from=build /app/build /app/build

ENV DATA_DIR=/app/data
CMD pnpm start
32 changes: 0 additions & 32 deletions default.nix

This file was deleted.

58 changes: 0 additions & 58 deletions docker.nix

This file was deleted.

93 changes: 0 additions & 93 deletions flake.lock

This file was deleted.

32 changes: 0 additions & 32 deletions flake.nix

This file was deleted.

5 changes: 0 additions & 5 deletions nixos/clansty-flake.nix

This file was deleted.

Loading

0 comments on commit 27e7595

Please sign in to comment.