Skip to content

Commit

Permalink
Merge pull request #225 from sebbo2002/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 authored Jan 7, 2024
2 parents 9330137 + 494dce9 commit acfffaf
Show file tree
Hide file tree
Showing 12 changed files with 1,177 additions and 860 deletions.
20 changes: 20 additions & 0 deletions .depfu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
update_strategy: "individual"

dev_update_strategy: "grouped"
grouped_dev_update_schedule: "weekly"
grouped_dev_update_start_date: "2023-11-21"
grouped_dev_update_time: "08:00"

reasonably_up_to_date: true
update_out_of_spec: true

automerge_strategy: "minor"
automerge_dev_strategy: "major"
automerge_method: "rebase"

engine_update_strategy: "major"

commit_message: "chore(deps): update {{dependency}} to version {{version}}"
commit_message_grouped: "chore(deps): Update {{update_type}} {{project_type}} dependencies ({{date}})"
labels: "dependencies"
auto_assign: "sebbo2002"
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.github
.nyc_output
dist
docs
node_modules
src
test
2 changes: 1 addition & 1 deletion .github/workflows/release-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
repository: sebbo2002/release-bot
path: ./.actions/release-bot
- name: 🔧 Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
pull-requests: write
steps:
- name: 🧹 Cleanup issues & pull requests
uses: actions/stale@v8
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: |
Expand Down
112 changes: 31 additions & 81 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
if: github.repository != 'sebbo2002/js-template' && (contains(toJson(github.event.commits.*.message), '[skip ci]') == false || github.ref == 'refs/heads/main')
strategy:
matrix:
node: [16.x, 18.x, 20.x]
node: [18.x, 20.x, current]
steps:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
Expand All @@ -43,7 +43,7 @@ jobs:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'npm'
- name: 📦 Install dependencies
Expand All @@ -65,7 +65,7 @@ jobs:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'npm'
- name: 📦 Install dependencies
Expand Down Expand Up @@ -101,66 +101,19 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: ℹ️ Set Build Variables
id: buildVars
run: echo "::set-output name=date::$(date +'%Y-%m-%d %H:%M:%S')"
- name: 🪄 Build and push (1/2)
uses: docker/build-push-action@v5
continue-on-error: true
id: docker-build-1-1
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
target: build-container
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
pull: true
push: true
tags: ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-from: ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-to: type=inline
- name: 🪄 Build and push (1/2, second try)
uses: docker/build-push-action@v5
continue-on-error: true
if: steps.docker-build-1-1.outcome=='failure'
id: docker-build-1-2
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
target: build-container
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
pull: true
push: true
tags: ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-from: ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-to: type=inline
- name: 🪄 Build and push (1/2, third try)
uses: docker/build-push-action@v5
continue-on-error: true
if: steps.docker-build-1-2.outcome=='failure'
id: docker-build-1-3
run: echo "date=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
- name: 🔧 Setup node.js
uses: actions/setup-node@v4
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
target: build-container
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
pull: true
push: true
tags: ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-from: ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-to: type=inline
- name: 🪄 Build and push (1/2; Summary)
if: always()
run: |
if ${{ steps.docker-build-1-1.outcome=='success' || steps.docker-build-1-2.outcome=='success' || steps.docker-build-1-3.outcome=='success' }}; then
echo "🎉 Whoop whoop, that worked…"
else
exit 1
fi
- name: 🪄 Build and push (2/2)
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: ⚙️ Build project
run: npm run build
- name: 🪄 Build and push
uses: docker/build-push-action@v5
continue-on-error: true
id: docker-build-2-1
id: docker-build-1
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -178,14 +131,13 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
cache-from: |
ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:cache-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:next
- name: 🪄 Build and push (2/2; second try)
- name: 🪄 Build and push (second try)
uses: docker/build-push-action@v5
continue-on-error: true
if: steps.docker-build-2-1.outcome=='failure'
id: docker-build-2-2
if: steps.docker-build-1.outcome=='failure'
id: docker-build-2
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -203,14 +155,13 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
cache-from: |
ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:cache-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:next
- name: 🪄 Build and push (2/2; third try)
- name: 🪄 Build and push (third try)
uses: docker/build-push-action@v5
if: steps.docker-build-2-2.outcome=='failure'
if: steps.docker-build-2.outcome=='failure'
continue-on-error: true
id: docker-build-2-3
id: docker-build-3
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -228,23 +179,22 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
cache-from: |
ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:cache-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:next
cache-to: type=inline
- name: 🪄 Build and push (2/2; Summary)
- name: 🪄 Build and push (Summary)
if: always()
id: docker-build-2
id: docker-build
run: |
if ${{ steps.docker-build-2-1.outcome=='success' }}; then
if ${{ steps.docker-build-1.outcome=='success' }}; then
echo "🎉 Whoop whoop, that worked (first try)"
echo "::set-output name=digest::${{ steps.docker-build-2-1.outputs.digest }}"
elif ${{ steps.docker-build-2-2.outcome=='success' }}; then
echo "digest=${{ steps.docker-build-1.outputs.digest }}" >> $GITHUB_OUTPUT
elif ${{ steps.docker-build-2.outcome=='success' }}; then
echo "🎉 Whoop whoop, that worked (second try)"
echo "::set-output name=digest::${{ steps.docker-build-2-2.outputs.digest }}"
elif ${{ steps.docker-build-2-3.outcome=='success' }}; then
echo "digest=${{ steps.docker-build-2.outputs.digest }}" >> $GITHUB_OUTPUT
elif ${{ steps.docker-build-3.outcome=='success' }}; then
echo "🎉 Whoop whoop, that worked (third try)"
echo "::set-output name=digest::${{ steps.docker-build-2-3.outputs.digest }}"
echo "digest=${{ steps.docker-build-3.outputs.digest }}" >> $GITHUB_OUTPUT
else
exit 1
fi
Expand All @@ -269,7 +219,6 @@ jobs:
cache-from: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:cache-${{ hashFiles('package*.json') }}
ghcr.io/${{ github.repository }}:build-container-${{ hashFiles('package*.json') }}
cache-to: type=inline
- name: 🏁 Boot-up Check
if: github.repository != 'sebbo2002/js-template' && env.GITLAB_URL && env.GITLAB_TOKEN
Expand All @@ -288,7 +237,7 @@ jobs:
GITLAB_URL: ${{ secrets.GITLAB_URL }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
outputs:
digest-gh: ${{ steps.docker-build-2.outputs.digest }}
digest-gh: ${{ steps.docker-build.outputs.digest }}
digest-dh: ${{ steps.docker-build-dh.outputs.digest }}

release:
Expand All @@ -300,6 +249,7 @@ jobs:
permissions:
contents: write
issues: write
packages: write
pull-requests: write
id-token: write
needs:
Expand All @@ -313,7 +263,7 @@ jobs:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
Expand Down
17 changes: 2 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
FROM node:lts-alpine@sha256:619ce27eb37c7c0476bd518085bf1ba892e2148fc1ab5dbaff2f20c56e50444d as build-container

WORKDIR "/app"

COPY package*.json "/app/"
RUN npm ci --verbose

COPY . "/app/"
RUN npm run build && \
rm -rf ./.github ./src ./test ./node_modules && \
ls -la /app


FROM node:lts-alpine@sha256:619ce27eb37c7c0476bd518085bf1ba892e2148fc1ab5dbaff2f20c56e50444d
ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
Expand All @@ -19,10 +6,10 @@ WORKDIR "/app"
RUN apk add --no-cache --update dumb-init && \
ln -s /app/dist/start.js /usr/local/bin/start

COPY --from=build-container /app/package*.json "/app/"
COPY package*.json "/app/"
RUN npm ci --only-production

COPY --from=build-container "/app" "/app"
COPY . "/app"
USER node

ENTRYPOINT ["/usr/bin/dumb-init", "--"]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Sebastian Pekarek
Copyright (c) 2024 Sebastian Pekarek

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand Down
Loading

0 comments on commit acfffaf

Please sign in to comment.