Skip to content

Commit

Permalink
Revert "Fix docker-compose.yml (#291)"
Browse files Browse the repository at this point in the history
This reverts commit a475e97.
  • Loading branch information
taheeraahmed committed Sep 21, 2023
1 parent a475e97 commit 5a8e7d2
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 55 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build docker stack
run: |
docker network create traefik
docker-compose -f docker-compose.yml -f docker-compose.test.yml up run-tests
lint:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Stage 1: Build the project

FROM maven:3.6.3-jdk-11-slim AS MAVEN_BUILD

MAINTAINER fg-web@samfundet.no
# Tomcat creates a working dir at /tmp by default. Might be optional
VOLUME /tmp
COPY pom.xml /build/
Expand All @@ -20,7 +19,5 @@ RUN apk --no-cache add openjdk11
WORKDIR /app
COPY --from=MAVEN_BUILD /build/target/*.jar /app/
RUN ls /app/

# To reduce startup time: adding /dev/urandom as a source of entropy
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/hilfling-0.0.1-SNAPSHOT.jar"]
EXPOSE 8000
52 changes: 52 additions & 0 deletions docker-compose.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is not designed to be used a lone, but
# As an addition to './docker-compose.yml' ex: 'docker-compose -f ./docker-compose.yml -f ./docker-compose.deploy.yml up -d'
version: "3"
networks:
traefik:
external: true
hilfling-network: # Used for internal networking

services:
postgres:
labels:
- traefik.enable=false

hilfling-backend:
container_name: hilfling-backend
image: fotogjengen/hilfling-backend
volumes:
- ./static-files/:/app/static-files/
depends_on:
- postgres
- fg-blob-storage
ports:
- 8484:8080
expose:
- 8080
networks:
- traefik
- hilfling-network
environment:
DATABASE_USERNAME: $DATABASE_USERNAME
DATABASE_PASSWORD: $DATABASE_PASSWORD
DATABASE_URL: "jdbc:postgresql://postgres:5432/hilflingdb" #"jdbc:postgresql://postgres:5432/hilflingdb?createDatabaseIfNotExist=true"

labels:
- traefik.enable=true
- traefik.http.routers.hilfling-backend.entrypoints=web # <== Defining the entrypoint for http, **ref: line 30
- traefik.http.routers.hilfling-backend.entrypoints=websecure # <== Defining the entrypoint for http, **ref: line 30
- traefik.http.routers.hilfling-backend.rule=Host(`fg-backend.nikzy.no`) # <== Your Domain Name goes here for the http rule
- traefik.http.routers.hilfling-backend.tls.certresolver=lets-encr # Adds SSL to App
- traefik.docker.network=traefik

fg-static:
#image: fotogjengen/hilfling-static # Don't need to push this to a registry
networks:
- traefik
labels:
- traefik.enable=true
- traefik.http.routers.hilfling-rontend.entrypoints=web # <== Defining the entrypoint for http, **ref: line 30
- traefik.http.routers.hilfling-static.entrypoints=websecure # <== Defining the entrypoint for http, **ref: line 30
- traefik.http.routers.hilfling-static.rule=Host(`fg-static.nikzy.no`) # <== Your Domain Name goes here for the http rule
- traefik.http.routers.hilfling-static.tls.certresolver=lets-encr # Adds SSL to App

2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ services:
DATABASE_URL: "jdbc:postgresql://postgres:5432/hilflingdb" #"jdbc:postgresql://postgres:5432/hilflingdb?createDatabaseIfNotExist=true"

labels:
- traefik.enable=false
- traefik.enable=false
84 changes: 54 additions & 30 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,71 @@
version: '3.7'
# This file uses environment variables
# to override any settings add a file called '.env'
# with new environment variable values
# example: "DATABASE_USERNAME=NikZy"
version: "3"
networks:
hilfling-network: # Used for internal networking

volumes:
db-data: # Data volume for the database

services:
app:
container_name: hilfling-app
ports:
- "8000:8000"
build:
context: .
dockerfile: Dockerfile
networks:
- hilfling-network
depends_on:
- postgres
environment:
DATABASE_HOST: postgres
DATABASE_USERNAME: hilfling
DATABASE_PASSWORD: password
DATABASE_NAME: hilflingdb
DATABASE_PORT: 5432

postgres:
container_name: hilflingdb
build:
context: .
dockerfile: postgres/Dockerfile
restart: always
networks:
- hilfling-network
volumes:
- "db-data:/var/lib/postgresql/data" # Database volume
#- "./postgres/sql:/base-sql" # Think this was init sql schema?
expose:
- 5432
networks:
- hilfling-network
ports:
- "5432:5432"
environment:
POSTGRES_USER: hilfling # Use POSTGRES_USER instead of DATABASE_USERNAME
POSTGRES_PASSWORD: password
POSTGRES_DB: hilflingdb # Specify the default database
POSTGRES_HOST_AUTH_METHOD: trust
# Use env variable if exists, fallback to hilfling
POSTGRES_USER: ${DATABASE_USERNAME:-hilfling}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-password}
LISTENING_PORT: ${LISTENING_PORT-8080}

networks:
hilfling-network:
driver: bridge
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-admin@admin.com}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-password}
ports:
- ${PGADMIN_PORT:-5050}:80
networks:
- hilfling-network

volumes:
db-data:
fg-static:
container_name: hilfling-static
#image: fotogjengen/hilfling-static # Don't need to push this to a registry
build:
context: ./static-files
dockerfile: Dockerfile
environment:
NGINX_HOST: ${NGINX_HOST:-fg-static.nikzy.no}
NGINX_PORT: ${NGINX_PORT:-80}
ports:
- 8383:${NGINX_PORT:-80}
volumes:
- ./static-files/static/:/usr/share/nginx/html

fg-blob-storage:
container_name: hilfling-blob-storage
image: mcr.microsoft.com/azure-storage/azurite
volumes:
- ./static-files/blob_storage/:/data
restart: always
networks:
- hilfling-network
ports:
- "10000:10000"
- "10001:10001"
- "10002:10002"
Empty file removed letsencrypt/acme.json
Empty file.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
<goal>generate</goal>
</goals>
<configuration>
<apiDocsUrl>http://localhost:8000/v3/api-docs</apiDocsUrl>
<apiDocsUrl>http://localhost:8080/v3/api-docs</apiDocsUrl>
<outputFileName>openapi.json</outputFileName>
<outputDir>${project.build.directory}</outputDir>
</configuration>
Expand Down
1 change: 1 addition & 0 deletions postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM postgres:12
MAINTAINER FG Web (fg-web@samfundet.no)

ENV POSTGRES_DB hilflingdb

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class ResourceConfiguration implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
Expand Down
24 changes: 7 additions & 17 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
server:
address:
- ${LISTENING_IP:localhost}
- 0.0.0.0
port: ${LISTENING_PORT:8000}
address: ${LISTENING_IP:localhost}
port: ${LISTENING_PORT:8080}
error:
include-message: always
include-stacktrace: always
include-exception: true
include-binding-errors: always
spring:
mvc:
cors:
allow-credentials: false
allowed-origins:
- http://localhost:3000
allowed-methods:
- GET
- POST
- PUT
- DELETE
allowed-headers: "*"
datasource:
hikari:
connection-timeout: 20000
maximum-pool-size: 5
username: ${DATABASE_USERNAME:hilfling}
url: ${DATABASE_URL:jdbc:postgresql://postgres:5432/hilflingdb?createDatabaseIfNotExist=true}
url: ${DATABASE_URL:jdbc:postgresql://localhost:5432/hilflingdb?createDatabaseIfNotExist=true}
password: ${DATABASE_PASSWORD:password}
driver-class-name: ${DATABASE_DRIVER:org.postgresql.Driver}

Expand All @@ -35,9 +22,10 @@ spring:
me.liuwj.ktorm: debug
org.springframework.web: DEBUG


flyway:
user: ${DATABASE_USERNAME:hilfling}
url: ${DATABASE_URL:jdbc:postgresql://postgres:5432/hilflingdb?createDatabaseIfNotExist=true}
url: ${DATABASE_URL:jdbc:postgresql://localhost:5432/hilflingdb?createDatabaseIfNotExist=true}
password: ${DATABASE_PASSWORD:password}
enabled: true
validate-on-migrate: true
Expand All @@ -61,6 +49,7 @@ spring:
blob-storage:
connection-string: ${AZURE_STORAGE_CONNECTION_STRING:DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;}


springdoc:
api-docs:
#path: "/"
Expand All @@ -77,6 +66,7 @@ file:
large-upload-dir: photos/large/
medium-upload-dir: photos/medium/
small-upload-dir: photos/small/

#okta: # SECURITY OKTA
# oauth2:
# issuer: https://dev-812828.okta.com/oauth2/default
Expand Down

0 comments on commit 5a8e7d2

Please sign in to comment.