Skip to content

Instantly share code, notes, and snippets.

View gadmel's full-sized avatar
💎
Don't panic & carry a towel

Gleb Abramov gadmel

💎
Don't panic & carry a towel
View GitHub Profile
@gadmel
gadmel / shell
Created March 1, 2023 16:45
printenv VARIABLES
printenv VARIABLES
@gadmel
gadmel / shell
Last active March 1, 2023 17:10
Start Docker with environment variable
docker run --env ENV_KEY=env_value -d -p 8080:8080 ImAgE-ID
Dockerfile:
FROM openjdk:19
EXPOSE 8080
WORKDIR /usr/src/myapp
ADD backend/target/app.jar app.jar
CMD ["sh", "-c", "java -jar app.jar", "-Dspring.profiles.active=${ENV_KEY}"]
@gadmel
gadmel / Dockerfile
Created February 28, 2023 22:14
Docker file for frontend-backend-application
FROM openjdk:19
EXPOSE 8080
WORKDIR /usr/src/myapp
ADD backend/target/app.jar app.jar
CMD ["sh", "-c", "java -jar app.jar"]
@gadmel
gadmel / build.sh
Created February 28, 2023 22:11
Docker build script shell for frontend-backend-application
cd frontend || exit
npm ci
npm run build
rm -rf ../backend/src/main/resources/static
mv build ../backend/src/main/resources/static
cd ../backend || exit
./mvnw clean package
cd ..
docker build -t {name-of-the-docker-image} .
@gadmel
gadmel / StaticFilesConfig.java
Created February 28, 2023 22:09
StaticFilesConfig.java
package com.example.backend.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
import java.io.IOException;
@gadmel
gadmel / sonar-frontend.yml
Created February 28, 2023 22:07
.github/workflows/sonar-frontend.yml
name: Build Frontend according to SonarCloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
@gadmel
gadmel / sonar-backend.yml
Created February 28, 2023 22:06
.github/workflows/sonar-backend.yml
name: Build Backend according to SonarCloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
@gadmel
gadmel / maven.yml
Created February 28, 2023 22:01
.github/workflows/maven.yml
name: Java CI - Build with Maven
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build: