Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init #97

Open
wants to merge 2 commits into
base: develop-6.2.x
Choose a base branch
from
Open

init #97

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "develop-6.2.x" ]
pull_request:
branches: [ "develop-6.2.x" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM node:12.21.0-buster-slim as base

# This image is NOT made for production use.
LABEL maintainer="Eero Ruohola <[email protected]>"


RUN apt-get update \
&& apt-get --assume-yes install \
libpangocairo-1.0-0 \
python3 \
python3-dev \
python3-pil \
python3-pip \
&& rm -rf /var/lib/apt/lists/ /var/cache/apt/

RUN python3 -m pip install --upgrade pip setuptools wheel django-prometheus \
&& pip3 install 'markupsafe==1.1.1'

# These invalidate the cache every single time but
# there really isn't any other obvious way to do this.
COPY . /app
WORKDIR /app

# The dev compose file sets this to 1 to support development and editing the source code.
# The default value of 0 just installs the demo for running.
ARG editable=0

RUN if [ "$editable" -eq 1 ]; then pip3 install -r requirements-tests.txt && python3 setup.py build_resources; else pip3 install shuup; fi
RUN pip install django-prometheus
RUN python3 -m shuup_workbench migrate
RUN python3 -m shuup_workbench shuup_init

RUN echo '\
from django.contrib.auth import get_user_model\n\
from django.db import IntegrityError\n\
try:\n\
get_user_model().objects.create_superuser("admin", "[email protected]", "admin")\n\
except IntegrityError:\n\
pass\n'\
| python3 -m shuup_workbench shell

CMD ["python3", "-m", "shuup_workbench", "runserver", "0.0.0.0:8000"]
11 changes: 11 additions & 0 deletions alert.rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
groups:
- name: SRE_FInal_alerts
rules:
- alert: ElevatedResponseTime
expr: http_request_duration_seconds_mean > 0.5
for: 1m
labels:
severity: critical
annotations:
summary: "Elevated Response Time Alert"
description: "The average response time has exceeded 0.5 seconds for over 1 minute."
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "3.7"

networks:
monitoring:
driver: bridge

volumes:
prometheus_data:
srefinal_app:

services:
srefinal_app:
image: srefinal_app
ports:
- "8080:8080"
restart: unless-stopped
networks:
- monitoring

prometheus:
container_name: prometheus
image: prom/prometheus:latest
volumes:
- /c/Users/gupra/Downloads/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9091:9090
depends_on:
- srefinal_app
restart: always
networks:
- monitoring
hostname: prometheus
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@
<artifactId>boot-community-demo-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>
</dependencyManagement>

<modules>
Expand Down
7 changes: 6 additions & 1 deletion site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.12.5</version>
</dependency>
</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
blPU.hibernate.hbm2ddl.auto=create
blEventPU.hibernate.hbm2ddl.auto=create

management.endpoints.web.exposure.include=prometheus
jmx.app.name=site
http.server.port=8080
server.port=8443
Expand Down
42 changes: 42 additions & 0 deletions site/src/main/resources/webTemplates/catalog/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM node:12.21.0-buster-slim as base

# This image is NOT made for production use.
LABEL maintainer="Eero Ruohola <[email protected]>"


RUN apt-get update \
&& apt-get --assume-yes install \
libpangocairo-1.0-0 \
python3 \
python3-dev \
python3-pil \
python3-pip \
&& rm -rf /var/lib/apt/lists/ /var/cache/apt/

RUN python3 -m pip install --upgrade pip setuptools wheel django-prometheus \
&& pip3 install 'markupsafe==1.1.1'

# These invalidate the cache every single time but
# there really isn't any other obvious way to do this.
COPY . /app
WORKDIR /app

# The dev compose file sets this to 1 to support development and editing the source code.
# The default value of 0 just installs the demo for running.
ARG editable=0

RUN if [ "$editable" -eq 1 ]; then pip3 install -r requirements-tests.txt && python3 setup.py build_resources; else pip3 install shuup; fi
RUN pip install django-prometheus
RUN python3 -m shuup_workbench migrate
RUN python3 -m shuup_workbench shuup_init

RUN echo '\
from django.contrib.auth import get_user_model\n\
from django.db import IntegrityError\n\
try:\n\
get_user_model().objects.create_superuser("admin", "[email protected]", "admin")\n\
except IntegrityError:\n\
pass\n'\
| python3 -m shuup_workbench shell

CMD ["python3", "-m", "shuup_workbench", "runserver", "0.0.0.0:8000"]