Skip to content

Commit

Permalink
⬆️ Upgrade config and add Dockerfile (#7)
Browse files Browse the repository at this point in the history
* ⬆️ Upgrade stuff and add Dockerfile

* 🔧 Add github extension

* 🔧 Dependabot

* 🐛 Fix dockerfile

* 🔧 A bit more act

* 📝 Add badges

* 🔧 pnpm-lock.yaml linguist-generated
  • Loading branch information
NatoBoram authored Dec 14, 2023
1 parent 6ecd572 commit 6c96ca8
Show file tree
Hide file tree
Showing 19 changed files with 347 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.git
.gitignore
*.md
dist
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
BUILD_BASE=/lmgtfy
BUILD_ADAPTER=auto
BUILD_BASE=
BUILD_IPFS=false
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
/.pnpm-store
package-lock.json
pnpm-lock.yaml
yarn.lock
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml linguist-generated
2 changes: 2 additions & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
patreon: NatoBoram
custom: ['https://paypal.me/NatoBoram/5']
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
timezone: America/Toronto
commit-message:
prefix: '⬆️ '
groups:
patch:
update-types:
- patch
eslint:
patterns:
- '*eslint*'
tailwindcss:
patterns:
- '*heroicons*'
- '*tailwindcss*'
- autoprefixer
- postcss
prettier:
patterns:
- '*prettier*'
svelte:
patterns:
- '*svelte*'
vite:
patterns:
- '*vitejs*'
- vite
typescript:
patterns:
- '*typescript*'
- tslib
48 changes: 48 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker

on:
push:
branches: main
tags: v*
pull_request:
branches: main

jobs:
docker:
runs-on: ubuntu-latest

if: ${{ github.actor != 'nektos/act' }}

permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v3

- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{version}}
- uses: docker/build-push-action@v4
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
secrets: |
BUILD_BASE=
13 changes: 9 additions & 4 deletions .github/workflows/github-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ name: GitHub Pages

on:
push:
branches: [main]
branches: main

jobs:
build:
runs-on: ubuntu-latest

if: ${{ github.actor != 'nektos/act' }}

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
Expand All @@ -16,10 +18,12 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 19
- run: pnpm install
node-version: 21
- run: pnpm install --frozen-lockfile
- run: pnpm run build
- uses: actions/upload-pages-artifact@v1
env:
BUILD_BASE: /lmgtfy
- uses: actions/upload-pages-artifact@v2
with:
path: build

Expand All @@ -38,3 +42,4 @@ jobs:

steps:
- uses: actions/deploy-pages@v1
id: deployment
8 changes: 4 additions & 4 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Node.js CI

on:
push:
branches: [main]
branches: main
pull_request:
branches: [main]
branches: main

jobs:
test:
Expand All @@ -18,12 +18,12 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 19
node-version: 21
# - uses: actions/cache@v3
# with:
# path: ~/.cache/ms-playwright
# key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm install
- run: pnpm install --frozen-lockfile --strict-peer-dependencies
#- run: npx playwright install
- run: pnpm run build
- run: pnpm run check
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
/.pnpm-store
package-lock.json
pnpm-lock.yaml
yarn.lock
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"recommendations": [
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"ms-azuretools.vscode-docker",
"ms-vscode.live-server",
"davidanson.vscode-markdownlint"
"svelte.svelte-vscode"
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"editor.minimap.maxColumn": 100,
"editor.rulers": [100]
},
"files.associations": {
"*.eslintignore": "ignore",
"*.prettierignore": "ignore"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:21-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

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

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=secret,id=BUILD_BASE BUILD_BASE="$(cat /run/secrets/BUILD_BASE)" BUILD_ADAPTER='node' pnpm run build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app/build
EXPOSE 3000
CMD [ "node", "./build/index.js" ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LMGTFY

[![Node.js CI](https://github.com/NatoBoram/lmgtfy/actions/workflows/node.js.yaml/badge.svg)](https://github.com/NatoBoram/lmgtfy/actions/workflows/node.js.yaml)
[![Docker](https://github.com/NatoBoram/lmgtfy/actions/workflows/docker.yaml/badge.svg)](https://github.com/NatoBoram/lmgtfy/actions/workflows/docker.yaml) [![GitHub Pages](https://github.com/NatoBoram/lmgtfy/actions/workflows/github-pages.yaml/badge.svg)](https://github.com/NatoBoram/lmgtfy/actions/workflows/github-pages.yaml) [![Node.js CI](https://github.com/NatoBoram/lmgtfy/actions/workflows/node.js.yaml/badge.svg)](https://github.com/NatoBoram/lmgtfy/actions/workflows/node.js.yaml)

A _Let Me Google That For You_ clone that's open source and doesn't track you when you share it.

Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:unit": "vitest",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
"format": "prettier --plugin-search-dir . --write .",
"docker:build": "docker build --secret id=BUILD_BASE --tag lmgtfy .",
"docker:run": "docker run --publish 127.0.0.1:3000:3000 lmgtfy",
"docker:kill": "docker ps --format '{{.Image}} {{.ID}}' | grep lmgtfy | awk '{print $2}' | xargs docker kill"
},
"devDependencies": {
"@natoboram/heroicons.svelte": "^1.0.1",
"@playwright/test": "^1.31.2",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/adapter-static": "^2.0.1",
"@sveltejs/kit": "^1.15.2",
"@typescript-eslint/eslint-plugin": "^5.56.0",
Expand Down
Loading

0 comments on commit 6c96ca8

Please sign in to comment.