Skip to content

Commit

Permalink
Log in to github got package repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjsr committed Apr 20, 2024
1 parent 3fc8145 commit 859f490
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ updates:
directory: '/'
schedule:
interval: 'weekly'
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
BUILDKIT_PROGRESS: plain
DBMIGRATE_IMAGE: tjsrowe/tagtool:dbmigrate-${{ github.sha }}
API_IMAGE: tjsrowe/tagtool:${{ github.sha }}
TAGTOOL_GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
TAGTOOL_GITHUB_PAT_2: ${{ secrets.TAGTOOL_GITHUB_PAT }}

steps:
- name: Check out repositofy code
Expand Down Expand Up @@ -42,6 +44,8 @@ jobs:
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
secrets: |
id=github,env=TAGTOOL_GITHUB_PAT
file: Dockerfile.dbmigrate
push: ${{ github.actor != 'dependabot[bot]' }}
tags: ${{ github.actor != 'dependabot[bot]' && format('{0}/', steps.login-ecr-public.outputs.registry) || ''}}${{ env.DBMIGRATE_IMAGE }}
Expand All @@ -53,6 +57,8 @@ jobs:
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
secrets: |
id=github,env=TAGTOOL_GITHUB_PAT
file: Dockerfile
push: ${{ github.actor != 'dependabot[bot]' }}
tags: ${{ github.actor != 'dependabot[bot]' && format('{0}/', steps.login-ecr-public.outputs.registry) || ''}}${{ env.API_IMAGE }}
Expand Down
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG NODE_VERSION=18.13.0
FROM node:${NODE_VERSION}-alpine3.17 as tagtool-build-preflight
ARG NPM_VERSION=9.6.3
RUN npm install -g npm@${NPM_VERSION}
ARG NODE_VERSION=20.12.2
ARG ALPINE_VERSION=3.19
ARG NPM_VERSION=10.5.2
FROM ghcr.io/tjsr/node_patched_npm:${NODE_VERSION}-alpine${ALPINE_VERSION}-npm${NPM_VERSION} as tagtool-build-preflight

RUN mkdir /opt/tagtool

Expand All @@ -18,14 +18,22 @@ COPY babel.config.js /opt/tagtool
COPY tsconfig.json /opt/tagtool
COPY .npmrc /opt/tagtool

RUN npm i && npm run build
RUN --mount=type=secret,id=github,target=/root/.npm/github_pat \
echo "//npm.pkg.github.com/:_authToken=$(cat /root/.npm/github_pat)" >> /root/.npmrc && \
npm install && \
npm run build && \
rm -f /root/.npmrc

FROM tagtool-build-preflight as tagtool

COPY package*.json /opt/tagtool
COPY .npmrc /opt/tagtool

RUN npm i --production
RUN --mount=type=secret,id=github,target=/root/.npm/github_pat \
echo "//npm.pkg.github.com/:_authToken=$(cat /root/.npm/github_pat)" >> /root/.npmrc && \
npm install --omit=dev && \
rm -f /root/.npmrc

COPY --from=tagtool-build /opt/tagtool/dist /opt/tagtool/dist
COPY --from=tagtool-build /opt/tagtool/build /opt/tagtool/dist/build
WORKDIR /opt/tagtool/dist
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile.dbmigrate
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
ARG NODE_VERSION=18.13.0
FROM node:${NODE_VERSION}-alpine3.17 as tagtool-dbmigrate
ARG NPM_VERSION=9.6.3

RUN npm install -g npm@${NPM_VERSION}
ARG NODE_VERSION=20.12.2
ARG ALPINE_VERSION=3.19
ARG NPM_VERSION=10.5.2
FROM ghcr.io/tjsr/node_patched_npm:${NODE_VERSION}-alpine${ALPINE_VERSION}-npm${NPM_VERSION} as tagtool-dbmigrate

RUN mkdir /opt/tagtool
COPY package.json /opt/tagtool
COPY package-lock.json /opt/tagtool
COPY prisma /opt/tagtool

WORKDIR /opt/tagtool
RUN npm i
RUN --mount=type=secret,id=github,target=/root/.npm/github_pat \
echo "//npm.pkg.github.com/:_authToken=$(cat /root/.npm/github_pat)" >> /root/.npmrc && \
npm install && \
rm -f /root/.npmrc

CMD ["npm", "run", "db:upgrade:deploy"]
Binary file modified README.md
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"start:dev": "nodemon index.ts && cross-env PORT=3008 react-scripts start",
"start:prod": "node index.js",
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider react-scripts build && tsc",
"docker:build": "docker build -t tagtool -f Dockerfile .",
"docker:build:dbmigrate": "docker build -t tagtool-dbmigrate -f Dockerfile.dbmigrate .",
"docker:build": "docker build --secret id=github,env=TAGTOOL_GITHUB_PAT -t tagtool -f Dockerfile .",
"docker:build:dbmigrate": "docker build --secret id=github,env=TAGTOOL_GITHUB_PAT -t tagtool-dbmigrate -f Dockerfile.dbmigrate .",
"docker:test": "npm run docker:build && docker run --rm --name tagtool-test -it tagtool npm i && npm test",
"lint": "eslint --fix \"./src/**/*.{ts,tsx}\"",
"prettier": "prettier --single-quote --write \"./src/**/*.{ts,tsx}\"",
Expand Down

0 comments on commit 859f490

Please sign in to comment.