-
Notifications
You must be signed in to change notification settings - Fork 2
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
9 changed files
with
672 additions
and
4 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,5 @@ | ||
node_modules | ||
.git | ||
.next | ||
.env | ||
.github |
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,74 @@ | ||
name: Docker build and push to repository | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
main_build_image: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
shortref: ${{ steps.prep.outputs.shortref }} | ||
tags: ${{ steps.prep.outputs.tags }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.ECR_SECRET_KEY }} | ||
aws-region: us-west-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
with: | ||
registry-type: public | ||
|
||
- name: Prepare | ||
id: prep | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} | ||
ECR_REGISTRY_ALIAS: d6h3d6x3 | ||
ECR_REPOSITORY: amboss-banco | ||
run: | | ||
DOCKER_IMAGE=$ECR_REGISTRY/$ECR_REGISTRY_ALIAS/$ECR_REPOSITORY | ||
SHORTREF=${GITHUB_SHA::8} | ||
TAGS="${DOCKER_IMAGE}:${SHORTREF}" | ||
# Set output parameters. | ||
echo "shortref=${SHORTREF}" >> $GITHUB_OUTPUT | ||
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | ||
- name: Check Image | ||
id: image_check | ||
env: | ||
ECR_TAG: ${{ steps.prep.outputs.tags }} | ||
run: docker manifest inspect $ECR_TAG && echo "imageExists=true" >> $GITHUB_OUTPUT || echo "imageExists=false" >> $GITHUB_OUTPUT | ||
|
||
- name: Setup Docker Buildx Driver | ||
id: docker_driver_setup | ||
if: ${{ steps.image_check.outputs.imageExists == 'false' }} | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: docker_build | ||
if: ${{ steps.image_check.outputs.imageExists == 'false' }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.prep.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Build Outputs | ||
if: ${{ steps.image_check.outputs.imageExists == 'false' }} | ||
run: | | ||
echo "Image ID: ${{ steps.docker_build.outputs.imageid }}" | ||
echo "Image Digest: ${{ steps.docker_build.outputs.digest }}" |
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 |
---|---|---|
|
@@ -34,3 +34,5 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
.env |
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 @@ | ||
v20.11.1 |
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,57 @@ | ||
FROM node:20.11.1-alpine as base | ||
|
||
# --------------- | ||
# Install Dependencies | ||
# --------------- | ||
FROM base AS deps | ||
|
||
RUN apk add --no-cache libc6-compat | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
|
||
# --------------- | ||
# Build App | ||
# --------------- | ||
FROM base AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN npm run build | ||
|
||
# --------------- | ||
# Final App | ||
# --------------- | ||
FROM base | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
ENV HOSTNAME 0.0.0.0 | ||
|
||
COPY ./scripts/startup.sh /startup.sh | ||
ENTRYPOINT ["sh", "/startup.sh" ] |
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
Oops, something went wrong.