-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
0 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,50 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
latest: | ||
description: "If the container should be tagged as latest." | ||
type: boolean | ||
required: false | ||
default: false | ||
push: | ||
description: "If the built container should be pushed." | ||
type: boolean | ||
required: false | ||
default: false | ||
|
||
jobs: | ||
build: | ||
name: Build docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Github Container Registry | ||
if: ${{ inputs.push }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create SHA Container Tag | ||
id: sha_tag | ||
run: | | ||
tag=$(cut -c 1-7 <<< $GITHUB_SHA) | ||
echo "::set-output name=tag::$tag" | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ inputs.push }} | ||
tags: | | ||
ghcr.io/abandontech/abandontechsite:${{ steps.sha_tag.outputs.tag }} | ||
${{ inputs.latest && 'ghcr.io/abandontech/abandontechsite:latest' || '' }} |
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,12 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: main | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
latest: true | ||
push: true |
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,13 @@ | ||
name: Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml |
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,33 @@ | ||
FROM node:20 as deps | ||
|
||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock ./ | ||
RUN yarn install | ||
|
||
FROM node:20-alpine AS builder | ||
|
||
WORKDIR /build | ||
|
||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
RUN yarn run nuxt build | ||
|
||
FROM builder AS runner | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN addgroup -g 1001 -S nodejs | ||
RUN adduser -S nuxt -u 1001 | ||
|
||
COPY --from=builder /build/.output ./.output | ||
|
||
USER nuxt | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["node", ".output/server/index.mjs"] |