Skip to content

Commit

Permalink
Merge pull request #611 from scc-digitalhub/5.x
Browse files Browse the repository at this point in the history
5.2-beta
  • Loading branch information
matteo-s authored Oct 25, 2024
2 parents 5c4fd41 + fa0dcf1 commit 3057160
Show file tree
Hide file tree
Showing 371 changed files with 38,144 additions and 297 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build_cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Create and publish a cache Docker image
on:
push:
branches:
- main
paths:
- '**pom.xml'
- '**package.json'
tags-ignore:
- "*"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Log in to the Container registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=cache
flavor: |
latest=false
- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile-cache
40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create and publish a Docker image
on:
release:
types: [published]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Log in to the Container registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"VER=${{ github.event.release.name }}"
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Prettier configuration
plugins:
- prettier-plugin-java
overrides:
- files:
- "*.java"
Expand Down
66 changes: 43 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,56 @@
# syntax=docker/dockerfile:experimental
ARG CACHE=ghcr.io/scc-digitalhub/aac:cache
FROM ${CACHE} AS cache

FROM maven:3-openjdk-17 as build
FROM maven:3-openjdk-17 AS build
ARG VER=SNAPSHOT
COPY ./src /tmp/src
COPY ./pom.xml /tmp/pom.xml
COPY ./user-console /tmp/user-console
COPY ./dev-console /tmp/dev-console
COPY ./admin-console /tmp/admin-console
WORKDIR /tmp
RUN --mount=type=cache,target=/root/.m2,source=/root/.m2,from=smartcommunitylab/aac:cache \
--mount=type=cache,target=/tmp/user-console/node_modules,source=/root/node_modules,from=smartcommunitylab/aac:cache \
mvn package
RUN --mount=type=cache,target=/root/.m2,source=/cache/.m2,from=cache \
--mount=type=cache,target=/tmp/target/node,source=/cache/target/node,from=cache \
--mount=type=cache,target=/tmp/user-console/node_modules,source=/cache/user-console/node_modules,from=cache \
--mount=type=cache,target=/tmp/dev-console/node_modules,source=/cache/dev-console/node_modules,from=cache \
--mount=type=cache,target=/tmp/admin-console/node_modules,source=/cache/admin-console/node_modules,from=cache \
mvn -Drevision=${VER} package

FROM eclipse-temurin:17-jdk-alpine as builder
FROM eclipse-temurin:17-jdk-alpine AS builder
WORKDIR /tmp
COPY --from=build /tmp/target/aac.jar aac.jar
RUN java -Djarmode=layertools -jar aac.jar extract


FROM eclipse-temurin:17-jdk-alpine
ARG USER=aac
ARG USER_ID=805
ARG USER_GROUP=aac
ARG USER_GROUP_ID=805
ARG USER_HOME=/home/${USER}
ENV FOLDER=/tmp/target
# FROM eclipse-temurin:17-jdk-alpine
# ARG USER=aac
# ARG USER_ID=805
# ARG USER_GROUP=aac
# ARG USER_GROUP_ID=805
# ARG USER_HOME=/home/${USER}
# ENV FOLDER=/tmp/target
# ENV APP=aac.jar
# # create a user group and a user
# RUN addgroup -g ${USER_GROUP_ID} ${USER_GROUP}; \
# adduser -u ${USER_ID} -D -g '' -h ${USER_HOME} -G ${USER_GROUP} ${USER} ;

# WORKDIR ${USER_HOME}
# COPY --chown=aac:aac --from=builder dependencies/ ${USER_HOME}
# COPY --chown=aac:aac --from=builder snapshot-dependencies/ ${USER_HOME}
# COPY --chown=aac:aac --from=builder spring-boot-loader/ ${USER_HOME}
# COPY --chown=aac:aac --from=builder application/ ${USER_HOME}
# USER 805
# ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]

FROM gcr.io/distroless/java17-debian12:nonroot
ENV APP=aac.jar
# create a user group and a user
RUN addgroup -g ${USER_GROUP_ID} ${USER_GROUP}; \
adduser -u ${USER_ID} -D -g '' -h ${USER_HOME} -G ${USER_GROUP} ${USER} ;

WORKDIR ${USER_HOME}
COPY --chown=aac:aac --from=builder dependencies/ ${USER_HOME}
COPY --chown=aac:aac --from=builder snapshot-dependencies/ ${USER_HOME}
COPY --chown=aac:aac --from=builder spring-boot-loader/ ${USER_HOME}
COPY --chown=aac:aac --from=builder application/ ${USER_HOME}
USER aac
WORKDIR /aac
LABEL org.opencontainers.image.source=https://github.com/scc-digitalhub/AAC
COPY --from=builder /tmp/dependencies/ ./
COPY --from=builder /tmp/snapshot-dependencies/ ./
COPY --from=builder /tmp/spring-boot-loader/ ./
COPY --from=builder /tmp/application/ ./
EXPOSE 8080
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]


30 changes: 22 additions & 8 deletions Dockerfile-cache
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
FROM maven:3-openjdk-17 as mvn
COPY ./src /tmp/src
COPY ./user-console /tmp/user-console
COPY ./pom.xml /tmp/pom.xml
WORKDIR /tmp
RUN mvn install -DskipTests
FROM maven:3-openjdk-17 AS cache
RUN mkdir -p /build/src /build/user-console /build/dev-console /build/admin-console
COPY ./pom.xml /build/pom.xml
COPY ./user-console/package.json /build/user-console
COPY ./user-console/yarn.lock /build/user-console
COPY ./dev-console/package.json /build/dev-console
COPY ./dev-console/yarn.lock /build/dev-console
COPY ./admin-console/package.json /build/admin-console
COPY ./admin-console/yarn.lock /build/admin-console

WORKDIR /build
RUN mvn dependency:go-offline
RUN mvn clean generate-resources

FROM scratch
COPY --from=mvn /root/.m2 /root/.m2
COPY --from=mvn /tmp/user-console/node_modules /root/node_modules
LABEL org.opencontainers.image.source=https://github.com/scc-digitalhub/digitalhub-core
WORKDIR /cache
COPY --from=cache /root/.m2 /cache/.m2
COPY --from=cache /build/target /cache/target
COPY --from=cache /build/user-console/node_modules /cache/user-console/node_modules
COPY --from=cache /build/dev-console/node_modules /cache/dev-console/node_modules
COPY --from=cache /build/admin-console/node_modules /cache/admin-console/node_modules


4 changes: 4 additions & 0 deletions admin-console/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REACT_APP_API_URL=
REACT_APP_USER_CONSOLE=/console/user
REACT_APP_DEVELOPER_CONSOLE=/console/dev
REACT_APP_ADMIN_CONSOLE=/console/admin
4 changes: 4 additions & 0 deletions admin-console/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REACT_APP_API_URL=http://localhost:8080
REACT_APP_USER_CONSOLE=http://localhost:8080/console/user
REACT_APP_DEVELOPER_CONSOLE=http://localhost:8080/console/dev
REACT_APP_ADMIN_CONSOLE=http://localhost:8080/console/admin
31 changes: 31 additions & 0 deletions admin-console/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["react-app", "plugin:prettier/recommended"],
"plugins": [
"@typescript-eslint",
"import",
"jsx-a11y",
"prettier",
"react",
"react-hooks"
],
"rules": {
"no-use-before-define": "off",
"prettier/prettier": "error",
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "@mui/material",
"importNames": ["makeStyles", "createMuiTheme"],
"message": "Please import from @mui/material/styles instead. See https://material-ui.com/guides/minimizing-bundle-size/#option-2 for more information"
}
]
}
],
"no-redeclare": "off",
"import/no-anonymous-default-export": "off",
"@typescript-eslint/no-redeclare": ["error"]
}
}
23 changes: 23 additions & 0 deletions admin-console/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
15 changes: 15 additions & 0 deletions admin-console/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
jsxBracketSameLine: false,
jsxSingleQuote: false,
printWidth: 80,
quoteProps: 'as-needed',
rangeStart: 0,
rangeEnd: Infinity,
semi: true,
singleQuote: true,
tabWidth: 4,
trailingComma: 'es5',
useTabs: false
}
15 changes: 15 additions & 0 deletions admin-console/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
]
}
46 changes: 46 additions & 0 deletions admin-console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
Loading

0 comments on commit 3057160

Please sign in to comment.