This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docker): improved docker config
- Loading branch information
1 parent
44bc8d3
commit f7fb272
Showing
4 changed files
with
113 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Docker nightly release | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
check_date: | ||
runs-on: ubuntu-latest | ||
name: Check latest commit | ||
outputs: | ||
should_run: ${{ steps.should_run.outputs.should_run }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: print latest_commit | ||
run: echo ${{ github.sha }} | ||
|
||
- id: should_run | ||
continue-on-error: true | ||
name: check latest commit is less than a day | ||
if: ${{ github.event_name == 'schedule' }} | ||
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" | ||
|
||
ci: | ||
runs-on: ubuntu-latest | ||
needs: check_date | ||
if: ${{ needs.check_date.outputs.should_run != 'false' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm i | ||
|
||
- name: Run unit test | ||
run: pnpm test | ||
|
||
- name: Build the app | ||
run: pnpm build | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- ci | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
corentinth/snut:nightly | ||
ghcr.io/corentinth/snut:nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
FROM node:16-alpine as development | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
RUN apk add --update sqlite | ||
|
||
FROM node:16.20-alpine AS build | ||
WORKDIR /app | ||
RUN npm install -g pnpm | ||
RUN apk add --update python3 make g++ sqlite && rm -rf /var/cache/apk/* | ||
COPY . . | ||
RUN pnpm i --frozen-lockfile | ||
RUN pnpm build | ||
|
||
RUN npm run build | ||
|
||
FROM node:16-alpine as production | ||
|
||
FROM node:16.20-alpine as production | ||
ARG NODE_ENV=production | ||
ENV NODE_ENV=${NODE_ENV} | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN apk add --update sqlite | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install --only=production | ||
|
||
COPY . . | ||
|
||
COPY --from=development /usr/src/app/dist ./dist | ||
|
||
CMD ["node", "dist/main"] | ||
WORKDIR /app | ||
RUN apk add --update sqlite && rm -rf /var/cache/apk/* | ||
COPY --from=build /app/node_modules ./node_modules | ||
COPY --from=build /app/dist ./dist | ||
COPY --from=build /app/package*.json ./ | ||
COPY --from=build /app/views ./views | ||
COPY --from=build /app/public ./public | ||
EXPOSE 3000 | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
version: '3' | ||
|
||
version: '3.9' | ||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- NODE_ENV=production | ||
environment: | ||
- PORT=3000 | ||
- DATABASE_PATH=/usr/src/app/db/db.sqlite | ||
snut: | ||
image: 'corentinth/snut:latest' | ||
container_name: snut | ||
ports: | ||
- 3000:3000 | ||
- '3000:3000' | ||
environment: | ||
- DATABASE_PATH=/app/db/db.sqlite | ||
volumes: | ||
- ./test-db:/usr/src/app/db | ||
- '.db:/app/db' | ||
restart: unless-stopped | ||
volumes: | ||
test-db: |