Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
SnO2WMaN committed Dec 19, 2023
0 parents commit bd2d0db
Show file tree
Hide file tree
Showing 11 changed files with 1,574 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# deps
node_modules
33 changes: 33 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docker Images

on:
push:
branches:
- main
pull_request:
merge_group:

jobs:
build_graphql_api:
name: Docker Image (Nicovideo Updater)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
submodules: true
- uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
with:
dockerfile: Dockerfile
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3
- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/${{ github.repository_owner }}/nicovide-updater:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "prisma"]
path = prisma
url = https://github.com/otomadb/main-prisma
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Builder
FROM node:20.10.0-slim@sha256:e941e22afee9c5d1e96f7e3db939894c053f015e45ad9920793d78a6234dfe11 AS builder
WORKDIR /build

# install OpenSSL
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY ./package.json ./package-lock.json ./
RUN npm ci --ignore-scripts

COPY . .
RUN npm run build

# Runner
FROM node:20.10.0-slim@sha256:e941e22afee9c5d1e96f7e3db939894c053f015e45ad9920793d78a6234dfe11 AS runner
WORKDIR /app

# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

## install tini
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /bin/tini
RUN chmod +x /bin/tini

## install production-only node.js dependencies
ENV NODE_ENV production

## copy build dist
COPY --from=builder /build/node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node ./node_modules/@prisma/client/libquery_engine-debian-openssl-3.0.x.so.node
COPY --from=builder /build/dist ./dist

ENTRYPOINT ["tini", "--"]
CMD ["node", "./dist/main.mjs"]
19 changes: 19 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import esbuild from "esbuild";

await esbuild.build({
logLevel: "info",
bundle: true,
entryPoints: ["./src/main.ts"],
outdir: "./dist",
outExtension: { ".js": ".mjs" },
platform: "node",
format: "esm",
minify: true,
banner: {
js: `
const require = (await import("node:module")).createRequire(import.meta.url);
const __filename = (await import("node:url")).fileURLToPath(import.meta.url);
const __dirname = (await import("node:path")).dirname(__filename);
`,
},
});
Loading

0 comments on commit bd2d0db

Please sign in to comment.