diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 0000000..dffe784 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1,6 @@ +# Ignore generated theme +generated/* + +# Ignore source code +*/*/source + diff --git a/docker/build.sh b/docker/build.sh index 34f3293..6fcb293 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -12,12 +12,8 @@ cd "${SCRIPT_DIR}" source ./include.functions.sh # Set variables we will re-use multiple times -PROFILE_PATH="${GENERATED_DIRECTORY}/${CUSTOM_PROFILE_FILENAME}" DOCKER_COMPOSE_ORIGINAL_PATH="${GENERATED_DIRECTORY}/docker-compose-original.yaml" -# Set variable with whether the custom profile file is found -[[ -f "${PROFILE_PATH}" ]] && PROFILE_PATH_FOUND=0 || PROFILE_PATH_FOUND=1 - #################### ### Validations ### ################### @@ -27,6 +23,8 @@ if ! ( [[ -d "${GENERATED_DIRECTORY}" ]] || [[ -f "${DOCKER_COMPOSE_ORIGINAL_PAT _error 'Generated directory not found. Use prepare.sh to generate one first.' fi +: ${SFTP_READONLY_PASSWORD?'ENV variable SFTP_READONLY_PASSWORD is required if a database needs to be built'} + ##################### ### The real deal ### ##################### @@ -54,4 +52,4 @@ echo # Build images echo '# Building images' -_docker-compose -f "${DOCKER_COMPOSE_PATH}" --project-directory "${GENERATED_DIRECTORY}" build --pull --parallel +_docker-compose -f "${DOCKER_COMPOSE_PATH}" --project-directory "${GENERATED_DIRECTORY}" build --pull --parallel --build-arg SFTP_READONLY_PASSWORD="${SFTP_READONLY_PASSWORD}" diff --git a/docker/common/api/Dockerfile b/docker/common/api/Dockerfile index e3d16a6..2b8a519 100644 --- a/docker/common/api/Dockerfile +++ b/docker/common/api/Dockerfile @@ -4,11 +4,11 @@ FROM maven:3-eclipse-temurin-17 as builder WORKDIR /app # First download as many dependencies as possible. This avoids downloading all dependencies each time something in source changes -COPY pom.xml /app +COPY source/pom.xml /app RUN mvn clean package -Dmaven.main.skip -Dmaven.test.skip -Dspring-boot.repackage.skip && rm -r target # Next do the actual build -COPY . /app +COPY source /app RUN mvn clean package # Move the resultant jar to a known name so it can be picked up by the final image. diff --git a/docker/common/database/Dockerfile b/docker/common/database/Dockerfile index f71be88..420a305 100644 --- a/docker/common/database/Dockerfile +++ b/docker/common/database/Dockerfile @@ -13,13 +13,14 @@ ARG DATABASE_VERSION # DBSOURCE_PATH should be the path containing our database source # DATABASE_NAME will be the resulting database name ENV DBDATA_PATH="/data_emission_service/db-data/aeriusII" \ - DBCONFIG_PATH="/source/aerius-emission-database" \ + DBSOURCE_PATH="/source/database" \ + DBCONFIG_PATH="/source/database" \ DBRUNSCRIPT="docker" \ - DBSOURCE_PATH="/source/aerius-emission-database" \ + DBDATA_CLEANUP="false" \ DATABASE_NAME="emissions" # Copy over the database source files -COPY source/ /source/aerius-emission-database +COPY source/ /source # Start the actual database build RUN --mount=id=aerius-dbdata,type=cache,target=/data_emission_service/db-data \ diff --git a/docker/copy_dependencies_common.sh b/docker/copy_dependencies_common.sh index 1d47dff..2ba3202 100755 --- a/docker/copy_dependencies_common.sh +++ b/docker/copy_dependencies_common.sh @@ -29,7 +29,7 @@ fi # This service is build within docker, so move the source to the correct location if _is_module_enabled "${1}" 'api'; then cp -auv "${SOURCE_DIR}"/source/rest-service \ - "${DOCKER_COMMON_DIR}"/api/ + "${DOCKER_COMMON_DIR}"/api/source fi # Change current directory to previous one so scripts calling this one can function properly