Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Commit f7fb272

Browse files
committed
chore(docker): improved docker config
1 parent 44bc8d3 commit f7fb272

File tree

4 files changed

+113
-43
lines changed

4 files changed

+113
-43
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Docker nightly release
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
check_date:
10+
runs-on: ubuntu-latest
11+
name: Check latest commit
12+
outputs:
13+
should_run: ${{ steps.should_run.outputs.should_run }}
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: print latest_commit
17+
run: echo ${{ github.sha }}
18+
19+
- id: should_run
20+
continue-on-error: true
21+
name: check latest commit is less than a day
22+
if: ${{ github.event_name == 'schedule' }}
23+
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
24+
25+
ci:
26+
runs-on: ubuntu-latest
27+
needs: check_date
28+
if: ${{ needs.check_date.outputs.should_run != 'false' }}
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
- run: corepack enable
33+
- uses: actions/setup-node@v3
34+
with:
35+
node-version: 16
36+
cache: 'pnpm'
37+
38+
- name: Install dependencies
39+
run: pnpm i
40+
41+
- name: Run unit test
42+
run: pnpm test
43+
44+
- name: Build the app
45+
run: pnpm build
46+
47+
build:
48+
runs-on: ubuntu-latest
49+
needs:
50+
- ci
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
56+
- name: Login to GitHub Container Registry
57+
uses: docker/login-action@v1
58+
with:
59+
registry: ghcr.io
60+
username: ${{ github.repository_owner }}
61+
password: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Login to Docker Hub
64+
uses: docker/login-action@v2
65+
with:
66+
username: ${{ secrets.DOCKERHUB_USERNAME }}
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}
68+
69+
- name: Set up QEMU
70+
uses: docker/setup-qemu-action@v2
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v2
74+
75+
- name: Build and push
76+
uses: docker/build-push-action@v4
77+
with:
78+
context: .
79+
file: ./Dockerfile
80+
platforms: linux/amd64,linux/arm64
81+
push: true
82+
tags: |
83+
corentinth/snut:nightly
84+
ghcr.io/corentinth/snut:nightly

Dockerfile

+16-27
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
FROM node:16-alpine as development
2-
3-
WORKDIR /usr/src/app
4-
5-
COPY package*.json ./
6-
7-
RUN npm install
8-
RUN apk add --update sqlite
9-
1+
FROM node:16.20-alpine AS build
2+
WORKDIR /app
3+
RUN npm install -g pnpm
4+
RUN apk add --update python3 make g++ sqlite && rm -rf /var/cache/apk/*
105
COPY . .
6+
RUN pnpm i --frozen-lockfile
7+
RUN pnpm build
118

12-
RUN npm run build
13-
14-
FROM node:16-alpine as production
15-
9+
FROM node:16.20-alpine as production
1610
ARG NODE_ENV=production
1711
ENV NODE_ENV=${NODE_ENV}
18-
19-
WORKDIR /usr/src/app
20-
21-
RUN apk add --update sqlite
22-
23-
COPY package*.json ./
24-
25-
RUN npm install --only=production
26-
27-
COPY . .
28-
29-
COPY --from=development /usr/src/app/dist ./dist
30-
31-
CMD ["node", "dist/main"]
12+
WORKDIR /app
13+
RUN apk add --update sqlite && rm -rf /var/cache/apk/*
14+
COPY --from=build /app/node_modules ./node_modules
15+
COPY --from=build /app/dist ./dist
16+
COPY --from=build /app/package*.json ./
17+
COPY --from=build /app/views ./views
18+
COPY --from=build /app/public ./public
19+
EXPOSE 3000
20+
CMD ["npm", "start"]

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
Another pastebin with a clean and minimalist ui. Made for selfhosting.
44

5+
Use it online : [snut.thomasset.co](https://snut.thomasset.co/)
6+
57
![screenshot](./.github/screenshot.png)
68

79
## Host your instance
810

911
### Installation
1012

11-
Install using docker
13+
```shell
14+
docker run -d --restart unless-stopped -v $(pwd)/db:/app/db -e DATABASE_PATH=/app/db/db.sqlite -p 3000:3000 --name snut corentinth/snut:latest
15+
```
1216

1317
### Configuration
1418

docker-compose.yml

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
version: '3'
2-
1+
version: '3.9'
32
services:
4-
app:
5-
build:
6-
context: .
7-
dockerfile: Dockerfile
8-
args:
9-
- NODE_ENV=production
10-
environment:
11-
- PORT=3000
12-
- DATABASE_PATH=/usr/src/app/db/db.sqlite
3+
snut:
4+
image: 'corentinth/snut:latest'
5+
container_name: snut
136
ports:
14-
- 3000:3000
7+
- '3000:3000'
8+
environment:
9+
- DATABASE_PATH=/app/db/db.sqlite
1510
volumes:
16-
- ./test-db:/usr/src/app/db
11+
- '.db:/app/db'
1712
restart: unless-stopped
18-
volumes:
19-
test-db:

0 commit comments

Comments
 (0)