diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..25b1e09 --- /dev/null +++ b/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + com.github.egnaf + spring-boot-docker-examples + pom + 1.0 + + spring-boot + spring-boot-postgres + spring-boot-postgres-vue/backend + spring-boot-postgres-vue-nginx/backend + + \ No newline at end of file diff --git a/spring-boot-postgres-vue-nginx/.nginx/Dockerfile b/spring-boot-postgres-vue-nginx/.nginx/Dockerfile new file mode 100644 index 0000000..5cdc674 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/.nginx/Dockerfile @@ -0,0 +1,8 @@ +# Get the base default nginx image from docker hub +FROM nginx + +# Delete the existing default.conf +RUN rm /etc/nginx/conf.d/default.conf + +# Copy the custom default.conf to the nginx configuration +COPY default.conf /etc/nginx/conf.d \ No newline at end of file diff --git a/spring-boot-postgres-vue-nginx/.nginx/default.conf b/spring-boot-postgres-vue-nginx/.nginx/default.conf new file mode 100644 index 0000000..4acc8a1 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/.nginx/default.conf @@ -0,0 +1,12 @@ +server { + listen 80; + server_name nginx; + + location / { + proxy_pass http://frontend:3000; + } + + location /api/v1 { + proxy_pass http://backend:8080; + } +} \ No newline at end of file diff --git a/spring-boot-postgres-vue-nginx/backend/Dockerfile b/spring-boot-postgres-vue-nginx/backend/Dockerfile new file mode 100644 index 0000000..46327fa --- /dev/null +++ b/spring-boot-postgres-vue-nginx/backend/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:8-jre-alpine +WORKDIR /app/backend +COPY target/demo.jar ./demo.jar +CMD ["/usr/bin/java", "-jar", "demo.jar"] diff --git a/spring-boot-postgres-vue-nginx/backend/pom.xml b/spring-boot-postgres-vue-nginx/backend/pom.xml new file mode 100644 index 0000000..1c6197b --- /dev/null +++ b/spring-boot-postgres-vue-nginx/backend/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + + com.company + app + 1.0 + jar + + + UTF-8 + 1.8 + 1.8 + + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.postgresql + postgresql + 42.2.2 + + + + + demo + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/spring-boot-postgres-vue-nginx/backend/src/main/java/com/company/app/Application.java b/spring-boot-postgres-vue-nginx/backend/src/main/java/com/company/app/Application.java new file mode 100644 index 0000000..1f135f5 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/backend/src/main/java/com/company/app/Application.java @@ -0,0 +1,12 @@ +package com.company.app; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-boot-postgres-vue-nginx/backend/src/main/resources/application.yml b/spring-boot-postgres-vue-nginx/backend/src/main/resources/application.yml new file mode 100644 index 0000000..2e29466 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/backend/src/main/resources/application.yml @@ -0,0 +1,27 @@ +server: + port: 8080 + servlet: + context-path: /api/v1 + +spring: + profiles: + active: dev + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://database:5432/demo?createDatabaseIfNotExist=true + username: root + password: root + jpa: + hibernate: + ddl-auto: create + show-sql: false + database: postgresql + database-platform: org.hibernate.dialect.PostgreSQLDialect + open-in-view: false + generate-ddl: false +logging: + pattern: + console: "%d %-5level %logger : %msg%n" + level: + org.springframework: INFO + org.hibernate: INFO diff --git a/spring-boot-postgres-vue-nginx/docker-compose.yml b/spring-boot-postgres-vue-nginx/docker-compose.yml new file mode 100644 index 0000000..784e2d4 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3' +services: + postgres: + container_name: postgres + image: postgres:latest + ports: + - "5432:5432" + environment: + - POSTGRES_DB=jobdealer + - POSTGRES_USER=root + - POSTGRES_PASSWORD=root + backend: + container_name: backend + build: ./backend + ports: + - "8080:8080" + depends_on: + - postgres + frontend: + container_name: frontend + build: ./frontend + ports: + - "3000:3000" + depends_on: + - backend + nginx: + container_name: nginx + image: proxy + build: ./.nginx + depends_on: + - backend + - frontend + ports: + - 80:80 + - 443:443 diff --git a/spring-boot-postgres-vue-nginx/frontend/.gitignore b/spring-boot-postgres-vue-nginx/frontend/.gitignore new file mode 100644 index 0000000..a0dddc6 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/.gitignore @@ -0,0 +1,21 @@ +.DS_Store +node_modules +/dist + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/spring-boot-postgres-vue-nginx/frontend/Dockerfile b/spring-boot-postgres-vue-nginx/frontend/Dockerfile new file mode 100644 index 0000000..f09cf73 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/Dockerfile @@ -0,0 +1,8 @@ +FROM node:lts-alpine +RUN npm install -g http-server +WORKDIR /app +COPY package*.json ./ +RUN npm install --production +COPY . . +RUN npm run build +CMD ["http-server", "dist", "-p", "3000"] diff --git a/spring-boot-postgres-vue-nginx/frontend/README.md b/spring-boot-postgres-vue-nginx/frontend/README.md new file mode 100644 index 0000000..b9c5255 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/README.md @@ -0,0 +1,24 @@ +# frontend + +## Project setup +``` +yarn install +``` + +### Compiles and hot-reloads for development +``` +yarn serve +``` + +### Compiles and minifies for production +``` +yarn build +``` + +### Lints and fixes files +``` +yarn lint +``` + +### Customize configuration +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/spring-boot-postgres-vue-nginx/frontend/public/favicon.ico b/spring-boot-postgres-vue-nginx/frontend/public/favicon.ico new file mode 100644 index 0000000..df36fcf Binary files /dev/null and b/spring-boot-postgres-vue-nginx/frontend/public/favicon.ico differ diff --git a/spring-boot-postgres-vue-nginx/frontend/public/index.html b/spring-boot-postgres-vue-nginx/frontend/public/index.html new file mode 100644 index 0000000..1fe8d73 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + frontend + + + +
+ + + diff --git a/spring-boot-postgres-vue-nginx/frontend/src/App.vue b/spring-boot-postgres-vue-nginx/frontend/src/App.vue new file mode 100644 index 0000000..fcc5662 --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/src/App.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/spring-boot-postgres-vue-nginx/frontend/src/assets/logo.png b/spring-boot-postgres-vue-nginx/frontend/src/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/spring-boot-postgres-vue-nginx/frontend/src/assets/logo.png differ diff --git a/spring-boot-postgres-vue-nginx/frontend/src/components/HelloWorld.vue b/spring-boot-postgres-vue-nginx/frontend/src/components/HelloWorld.vue new file mode 100644 index 0000000..879051a --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/src/components/HelloWorld.vue @@ -0,0 +1,58 @@ + + + + + + diff --git a/spring-boot-postgres-vue-nginx/frontend/src/main.js b/spring-boot-postgres-vue-nginx/frontend/src/main.js new file mode 100644 index 0000000..63eb05f --- /dev/null +++ b/spring-boot-postgres-vue-nginx/frontend/src/main.js @@ -0,0 +1,8 @@ +import Vue from 'vue' +import App from './App.vue' + +Vue.config.productionTip = false + +new Vue({ + render: h => h(App), +}).$mount('#app')