Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ logs
attachments
*.patch

#properties.env

#src/main/resources/environment-vars.yaml
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM maven:3.9.9-amazoncorretto-17 AS build
WORKDIR /app

COPY pom.xml ./
COPY src ./src

RUN mvn clean package -Pprod

FROM openjdk:17-jdk-slim
WORKDIR /app

COPY --from=build /app/target/*.jar jira.jar
COPY /resources /app/resources

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "/app/jira.jar"]
CMD ["--spring.profiles.active=prod"]
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,28 @@
- https://habr.com/ru/articles/259055/

Список выполненных задач:
...

Task 1. Анализ структуры проекта (onboarding).

Task 2. Удалены социальные сети: vk, yandex.

Task 3. Чувствительная информация вынесена в отдельный проперти файл:
логин,
пароль БД,
идентификаторы для OAuth регистрации/авторизации,
настройки почты.
Основной вариант properties.env; альтернативный - environment-vars.yaml.

Task 5. Написаны тесты для публичных методов контроллера ProfileRestController.

Task s.n. Рефакторинг сокращения TO -> DTO в классах и методах. Лучше читается и не путается с "to".

Task 6. Рефакторинг метода com.javarush.jira.bugtracking.attachment.FileUtil#upload,
чтобы он использовал современный подход для работы с файловой системмой.

Task 7. Новый функционал: добавление тегов к задаче (REST API + реализация на сервисе). Также добавлены тесты.

Task 11. Локализация на двух языках для шаблонов писем (mails) и стартовой страницы index.html.

Task s.n. + 9-10. Dockerfile для основного сервера. Docker-compose файл для запуска контейнера сервера
вместе с БД и nginx. Организация автоматизированного развертывания бд: sql -> changelog.xml.
72 changes: 39 additions & 33 deletions config/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
# https://losst.ru/ustanovka-nginx-ubuntu-16-04
# https://pai-bx.com/wiki/nginx/2332-useful-redirects-in-nginx/#1
# sudo iptables -A INPUT ! -s 127.0.0.1 -p tcp -m tcp --dport 8080 -j DROP
server {
listen 80;
worker_processes 1;

# https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration
gzip on;
gzip_types text/css application/javascript application/json;
gzip_min_length 2048;
events {
worker_connections 1024;
}

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root /opt/jirarush/resources;
http {
server {
listen 80;

if ($request_uri ~ ';') {return 404;}
error_log /var/log/nginx/myapp_error.log debug; # Логи ошибок для этого сервера
access_log /var/log/nginx/myapp_access.log; # Логи доступа для этого сервера

# proxy_cookie_flags ~ secure samesite=none;
# https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration
gzip on;
gzip_types text/css application/javascript application/json;
gzip_min_length 2048;

# static
location /static/ {
expires 30d;
access_log off;
}
location /robots.txt {
access_log off;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root /resources;

location ~ (/$|/view/|/ui/|/oauth2/) {
expires 0m;
proxy_pass http://localhost:8080;
proxy_connect_timeout 30s;
}
location ~ (/api/|/doc|/swagger-ui/|/v3/api-docs/) {
proxy_pass http://localhost:8080;
proxy_connect_timeout 150s;
}
location / {
try_files /view/404.html = 404;
if ($request_uri ~ ';') {return 404;}

# proxy_cookie_flags ~ secure samesite=none;
# static
location /static/ {
expires 30d;
access_log off;
}
location /robots.txt {
access_log off;
}
location ~ (/$|/view/|/ui/|/oauth2/) {
expires 0m;
proxy_pass http://localhost:8080;
proxy_connect_timeout 30s;
}
location ~ (/api/|/doc|/swagger-ui/|/v3/api-docs/) {
proxy_pass http://localhost:8080;
proxy_connect_timeout 150s;
}
location / {
try_files $uri /view/404.html =404;
}
}
}
}
62 changes: 62 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
services:
jira-app:
container_name: app
build: .
ports:
- "8080:8080"
env_file:
- properties.env
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/jira
SPRING_DATASOURCE_USERNAME: jira
SPRING_DATASOURCE_PASSWORD: JiraRush
depends_on:
db:
condition: service_healthy
networks:
- jira-spring
volumes:
- ~/jira/logs/app:/app/logs

db:
container_name: jira-db
image: postgres:latest
restart: always
environment:
POSTGRES_DB: jira
POSTGRES_USER: jira
POSTGRES_PASSWORD: JiraRush
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ]
interval: 5s
timeout: 3s
retries: 5
start_period: 5s
networks:
- jira-spring
volumes:
- postgres_data:/var/lib/postgresql/data/
- ~/jira/logs/postgres:/var/log/postgresql

nginx:
container_name: nginx
image: nginx:latest
restart: always
volumes:
- ~/jira/logs/nginx:/var/log/nginx
- ./config/nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
depends_on:
- jira-app
networks:
- jira-spring

networks:
jira-spring:
driver: bridge

volumes:
postgres_data:
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>

<!-- TestContainers -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.20.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.20.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
36 changes: 36 additions & 0 deletions properties.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Database env
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/jira
SPRING_DATASOURCE_USER=jira
SPRING_DATASOURCE_PASSWORD=JiraRush

# OAuth2 env
# GITHUB
GITHUB_CLIENT_ID=3d0d8738e65881fff266
GITHUB_CLIENT_SECRET=0f97031ce6178b7dfb67a6af587f37e222a16120
GITHUB_SCOPE=email

# Google
GOOGLE_CLIENT_ID=329113642700-f8if6pu68j2repq3ef6umd5jgiliup60.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
GOOGLE_SCOPE=email,profile

# GitLab
GITLAB_CLIENT_ID=b8520a3266089063c0d8261cce36971defa513f5ffd9f9b7a3d16728fc83a494
GITLAB_CLIENT_SECRET=e72c65320cf9d6495984a37b0f9cc03ec46be0bb6f071feaebbfe75168117004
GITLAB_CLIENT_NAME=GitLab
GITLAB_REDIRECT_URL="{baseUrl}/login/oauth2/code/{registrationId}"
GITLAB_AUTH_GRANT_TYPE=authorization_code
GITLAB_SCOPE=read_user

GITLAB_AUTH_URI=https://gitlab.com/oauth/authoriz
GITLAB_TOKEN_URI=https://gitlab.com/oauth/token
GITLAB_USER_INFO_URI=https://gitlab.com/api/v4/user
GITLAB_USER_NAME_ATTR=email

# Email env
EMAIL_SMTP_AUTH=true
EMAIL_STARTTLS_ENABLE=true
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USERNAME=jira4jr@gmail.com
EMAIL_PASSWORD=zdfzsrqvgimldzyj
21 changes: 10 additions & 11 deletions resources/mails/email-confirmation.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>JiraRush - подтверждение почты</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<p th:text="'Привет, ' + ${user.firstName} + '.'"/>
<p>Чтобы завершить настройку учетной записи и начать пользоваться JiraRush, подтвердите, что вы правильно указали вашу
электронную почту.</p>
<a th:href="${confirmationUrl}">Подтвердить почту</a>
</body>
<html th:lang="${#locale}" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="#{mails.confirm.header}">JiraRush - confirm email</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<p th:text="#{mails.hi} + ', ' + ${user.firstName} + '.'"/>
<p th:text="#{mails.message}">Before using JiraRush and complete account setup please confirm your email.</p>
<a th:href="${confirmationUrl}" th:text="#{mails.confirm.email}">Confirm email</a>
</body>
</html>
10 changes: 5 additions & 5 deletions resources/mails/password-reset.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
<title>JiraRush - установить новый пароль</title>
<title th:text="#{mails.password.title}">JiraRush - setup new password</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<p th:text="'Привет, ' + ${user.firstName} + '.'"/>
<p th:text="'Мы получили запрос на установку нового пароля JiraRush для учетной записи: ' + ${user.email} + '.'"/>
<a th:href="${resetUrl}">Установить пароль</a>
<p th:text="#{mails.hi} + ', '+ ${user.firstName} + '.'"/>
<p th:text="#{mails.message.request}+ ': ' + ${user.email} + '.'"/>
<a th:href="${resetUrl}" th:text="#{mails.password.setup}">Setup password</a>
</body>
</html>
5 changes: 5 additions & 0 deletions resources/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
}
}

/*.nav-link {*/
/* padding: 0.1rem 1rem;*/
/* font-size: 1rem;*/
/*}*/

.sidebar-nav, .accordion-body, .accordion-button, .accordion-button:not(.collapsed) {
background-color: var(--nav);
color: darkgray;
Expand Down
6 changes: 6 additions & 0 deletions resources/static/fontawesome/css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -8603,9 +8603,11 @@ readers do not read off random characters that represent icons */
content: "\f3e8";
}

/*
.fa-vk:before {
content: "\f189";
}
*/

.fa-untappd:before {
content: "\f405";
Expand Down Expand Up @@ -9955,9 +9957,11 @@ readers do not read off random characters that represent icons */
content: "\f3bc";
}

/*
.fa-yandex:before {
content: "\f413";
}
*/

.fa-readme:before {
content: "\f4d5";
Expand Down Expand Up @@ -10183,9 +10187,11 @@ readers do not read off random characters that represent icons */
content: "\f7c6";
}

/*
.fa-yandex-international:before {
content: "\f414";
}
*/

.fa-cc-amex:before {
content: "\f1f3";
Expand Down
Loading