Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
625f1d23d0 | |||
62a872f168 | |||
1f435d24a7 | |||
f6b7d69dcf | |||
5aeedf7adc | |||
fbbd2c2035 | |||
b55e96c8a5 | |||
c39efa9cb3 | |||
77ae0353b3 |
14
.classpath
14
.classpath
|
@ -8,12 +8,16 @@
|
|||
<attribute name="owner.project.facets" value="jst.web"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_172">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="C:/Users/margh/Downloads/ojdbc6.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/margh/Downloads/mysql-connector-java-5.1.39.jar"/>
|
||||
<classpathentry kind="output" path="build/classes"/>
|
||||
<!-- <classpathentry kind="lib" path="drivers/mysql-connector-java-5.1.39.jar"/> -->
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
/Dockerfile
|
||||
/docker-compose*
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
/build/
|
||||
/target/
|
||||
/.m2/
|
||||
|
|
6
.project
6
.project
|
@ -20,8 +20,14 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
|
|
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
20
Dockerfile
Normal file
20
Dockerfile
Normal file
|
@ -0,0 +1,20 @@
|
|||
FROM maven:latest AS builder
|
||||
|
||||
COPY . /src
|
||||
WORKDIR /src
|
||||
|
||||
RUN mvn clean install
|
||||
|
||||
FROM tomcat:8.5
|
||||
ARG PROJECT_NAME=centralino_brigate
|
||||
ARG PROJECT_VERS=0.2.0
|
||||
|
||||
RUN cd /usr/local/tomcat/webapps.dist/ \
|
||||
&& for FILE in *; do \
|
||||
echo "Symlinking: $FILE -> /usr/local/tomcat/webapps/$FILE"; \
|
||||
ln -s $PWD/$FILE /usr/local/tomcat/webapps/$FILE; \
|
||||
done
|
||||
COPY docker/tomcat-users.xml /usr/local/tomcat/conf/
|
||||
COPY docker/host-manager/context.xml /usr/local/tomcat/webapps.dist/host-manager/META-INF/context.xml
|
||||
COPY docker/manager/context.xml /usr/local/tomcat/webapps.dist/manager/META-INF/context.xml
|
||||
COPY --from=builder /src/target/${PROJECT_NAME}-${PROJECT_VERS}.war /usr/local/tomcat/webapps/
|
12
Dockerfile.build
Normal file
12
Dockerfile.build
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM maven:latest
|
||||
ARG uid=1000
|
||||
ARG gid=1000
|
||||
|
||||
RUN groupadd -g ${gid} app \
|
||||
&& useradd -m -d /src -u ${uid} -g ${gid} app
|
||||
|
||||
USER app
|
||||
WORKDIR /src
|
||||
|
||||
ENTRYPOINT ["mvn"]
|
||||
CMD ["clean", "install"]
|
45
README.md
Normal file
45
README.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
## Centralino Brigate
|
||||
|
||||
App in jsp per sostegno all'attività delle brigate di solidarietà.
|
||||
|
||||
## How to
|
||||
|
||||
### Prerequisiti
|
||||
|
||||
- `docker`
|
||||
- `docker-compose`
|
||||
|
||||
### Dev
|
||||
|
||||
Se si vuole tirar su un ambiente di sviluppo locale con tomcat e un db mysql
|
||||
|
||||
```
|
||||
$ docker-compose up
|
||||
```
|
||||
|
||||
Si troverà l'app a `http://localhost:8080/centralino_brigate-0.2.0/`. *ATTENZIONE*: NON è
|
||||
production-safe!
|
||||
|
||||
Se si vuole buildare l'artifatto (output in `war` nella cartella `target/`),
|
||||
per prima cosa creare l'immagine per il processo di build con maven (solo la prima volta):
|
||||
|
||||
```
|
||||
$ docker build -t unit/mvn-builder:latest -f Dockerfile.build .
|
||||
```
|
||||
|
||||
Dopo di che:
|
||||
|
||||
```
|
||||
$ docker run --rm -v $PWD:/src -t unit/mvn-builder:latest
|
||||
```
|
||||
|
||||
Se si vuole dettaglio sul processo di build
|
||||
|
||||
```
|
||||
$ docker run --rm -v $PWD:/src -t unit/mvn-builder:latest -e -X clean install
|
||||
```
|
||||
|
||||
|
||||
### Prod
|
||||
|
||||
TODO
|
24
docker-compose.yml
Normal file
24
docker-compose.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: mysql:5
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=password
|
||||
- MYSQL_DATABASE=brigate
|
||||
- MYSQL_USER=brigate
|
||||
- MYSQL_PASSWORD=password
|
||||
volumes:
|
||||
- /var/lib/mysql
|
||||
- ./sql/mysql/:/docker-entrypoint-initdb.d/
|
||||
ports:
|
||||
- 3306:3306
|
||||
|
||||
brigate:
|
||||
build:
|
||||
dockerfile: ./Dockerfile
|
||||
context: .
|
||||
image: unit/centralino_brigate:0.2.0
|
||||
ports:
|
||||
- 8080:8080
|
3
docker/host-manager/context.xml
Normal file
3
docker/host-manager/context.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<Context antiResourceLocking="false" privileged="true" >
|
||||
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
|
||||
</Context>
|
3
docker/manager/context.xml
Normal file
3
docker/manager/context.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<Context antiResourceLocking="false" privileged="true" >
|
||||
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
|
||||
</Context>
|
5
docker/tomcat-users.xml
Normal file
5
docker/tomcat-users.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<tomcat-users>
|
||||
<role rolename="admin-gui"/>
|
||||
<user username="unit" password="unit" roles="unit,admin-gui,manager-gui"/>
|
||||
</tomcat-users>
|
44
pom.xml
Normal file
44
pom.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>centralino_brigate</groupId>
|
||||
<artifactId>centralino_brigate</artifactId>
|
||||
<version>0.2.0</version>
|
||||
<packaging>war</packaging>
|
||||
<name>centralino_brigate</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.39</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warSourceDirectory>WebContent</warSourceDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
<!-- vim: set ft=xml et ts=2 sts=0: -->
|
|
@ -1,21 +0,0 @@
|
|||
use brigate;
|
||||
|
||||
|
||||
CREATE TABLE CONTATTI
|
||||
( NOME VARCHAR(255) NOT NULL,
|
||||
COGNOME VARCHAR(255) NOT NULL ,
|
||||
SERVIZIO_SOCIALE VARCHAR(255),
|
||||
AREA VARCHAR(255),
|
||||
INDIRIZZO VARCHAR(255) NOT NULL,
|
||||
TELEFONO INTEGER PRIMARY KEY,
|
||||
NUMERO INTEGER NOT NULL ,
|
||||
COMPOSIZIONE_NUCLEO VARCHAR(255) NOT NULL ,
|
||||
NOTE_SACCHETTO VARCHAR(255),
|
||||
ULTIMA_CONSEGNA DATE,
|
||||
EMAIL VARCHAR(256)
|
||||
) ;
|
||||
|
||||
|
||||
CREATE TABLE ORDINI
|
||||
( TELEFONO INTEGER PRIMARY KEy REFERENCES CONTATTI(TELEFONO)
|
||||
) ;
|
25
sql/mysql/script_mysql.sql
Normal file
25
sql/mysql/script_mysql.sql
Normal file
|
@ -0,0 +1,25 @@
|
|||
USE brigate;
|
||||
|
||||
CREATE TABLE contatti (
|
||||
nome VARCHAR(255) NOT NULL,
|
||||
cognome VARCHAR(255) NOT NULL,
|
||||
servizio_sociale VARCHAR(255),
|
||||
area VARCHAR(255),
|
||||
indirizzo VARCHAR(255) NOT NULL,
|
||||
telefono INT8 PRIMARY KEY,
|
||||
numero INT8 NOT NULL,
|
||||
composizione_nucleo VARCHAR(255) NOT NULL,
|
||||
note_sacchetto VARCHAR(255),
|
||||
ultima_consegna DATE,
|
||||
email VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE ordini (
|
||||
telefono INT8 PRIMARY KEY REFERENCES contatti (telefono)
|
||||
);
|
||||
|
||||
CREATE TABLE utenti (
|
||||
nickname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
ruolo VARCHAR(255)
|
||||
);
|
|
@ -12,7 +12,7 @@ import bean.Contatto;
|
|||
|
||||
public class ContattoDao implements ContattoDaoI {
|
||||
|
||||
OracleConnection c = new OracleConnection();
|
||||
MySqlConnection c = new MySqlConnection();
|
||||
|
||||
@Override
|
||||
public boolean create(String nome, String cognome, String servizio_sociale, String area, String indirizzo,
|
||||
|
|
|
@ -4,9 +4,12 @@ package dao;
|
|||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import util.Config;
|
||||
|
||||
public class MySqlConnection {
|
||||
|
||||
Config cfg = new Config();
|
||||
|
||||
public static void main(String[] args) {
|
||||
MySqlConnection c = new MySqlConnection();
|
||||
c.open();
|
||||
|
@ -17,10 +20,10 @@ public class MySqlConnection {
|
|||
|
||||
|
||||
public Connection open() {
|
||||
String nomeDriver = "com.mysql.driverDriver";
|
||||
String utente = "brigate"; //nome utente
|
||||
String password = "password"; //password
|
||||
String url = "jdbc:oracle:thin:@localhost:1521:orcl";
|
||||
String nomeDriver = "com.mysql.jdbc.Driver";
|
||||
String utente = cfg.getDbUser(); //nome utente
|
||||
String password = cfg.getDbPass(); //password
|
||||
String url = "jdbc:mysql://" + cfg.getDbHost() + ":" + cfg.getDbPort() + "/brigate?autoReconnect=true&useSSL=false";
|
||||
|
||||
try {
|
||||
Class.forName(nomeDriver);
|
||||
|
|
|
@ -9,7 +9,7 @@ import bean.Utente;
|
|||
|
||||
public class UtenteDao implements UtenteDaoI {
|
||||
|
||||
OracleConnection c = new OracleConnection();
|
||||
MySqlConnection c = new MySqlConnection();
|
||||
|
||||
@Override
|
||||
public boolean registrazione(String nickname, String password, String ruolo) {
|
||||
|
|
41
src/util/Config.java
Normal file
41
src/util/Config.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
package util;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.*;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class Config {
|
||||
Properties configFile;
|
||||
|
||||
public Config() {
|
||||
configFile = new java.util.Properties();
|
||||
try {
|
||||
configFile.load(this.getClass().getClassLoader().getResourceAsStream("/etc/brigate/brigate.conf"));
|
||||
} catch(FileNotFoundException ex) {
|
||||
System.out.println("Missing config file");
|
||||
}catch(Exception eta) {
|
||||
eta.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getDbUser() {
|
||||
String user = this.configFile.getProperty("db_user", "brigate");
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getDbPass() {
|
||||
String pass = this.configFile.getProperty("db_password", "password");
|
||||
return pass;
|
||||
}
|
||||
|
||||
public String getDbHost() {
|
||||
String host = this.configFile.getProperty("db_url", "db");
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getDbPort() {
|
||||
String port = this.configFile.getProperty("db_port", "3306");
|
||||
return port;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user