-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Add custom entrypoint script to copy initial data
- Loading branch information
Showing
2 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
FROM ubuntu:24.04 as build | ||
|
||
RUN apt-get update -y && apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
curl | ||
|
||
RUN apt-get update -y && apt-get install -y build-essential git curl | ||
WORKDIR /opt | ||
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d | ||
COPY . . | ||
ENV GEOSERVER_DATA_DIR /opt/geoserver/data_dir | ||
RUN GEOSERVER_DATA_DIR="${GEOSERVER_DATA_DIR}" ./bin/task download-geoserver-data | ||
ENV INIT_DATA_DIR /opt/init_data | ||
RUN GEOSERVER_DATA_DIR="${INIT_DATA_DIR}" ./bin/task download-geoserver-data | ||
|
||
FROM kartoza/geoserver:2.24.2 as geoserver | ||
COPY --from=build /opt/geoserver/data_dir /opt/geoserver/data_dir | ||
RUN apt-get update -y && apt-get install --no-install-recommends -y rsync | ||
ENV INIT_DATA_DIR /opt/init_data | ||
ENV GEOSERVER_DATA_DIR /opt/geoserver/data_dir | ||
COPY --from=build ${INIT_DATA_DIR} ${INIT_DATA_DIR} | ||
COPY custom-entrypoint.sh /scripts/custom-entrypoint.sh | ||
ENTRYPOINT ["/bin/bash", "/scripts/custom-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
: ${INIT_DATA_DIR:?} || exit 1 | ||
: ${GEOSERVER_DATA_DIR:?} || exit 1 | ||
|
||
# Ensure the GeoServer data directory exists | ||
mkdir -p ${GEOSERVER_DATA_DIR} | ||
|
||
echo "Copying initial data from ${INIT_DATA_DIR} to ${GEOSERVER_DATA_DIR}" | ||
|
||
# The -a option stands for "archive", which means it preserves the files' attributes | ||
# The -v option stands for "verbose" | ||
# The --ignore-existing option tells rsync to skip updating files that already exist in the destination directory | ||
rsync -av --ignore-existing ${INIT_DATA_DIR}/ ${GEOSERVER_DATA_DIR}/ | ||
|
||
set +x | ||
|
||
# Delegate to the original entrypoint | ||
# https://github.com/kartoza/docker-geoserver/blob/develop/scripts/entrypoint.sh | ||
exec /scripts/entrypoint.sh "$@" |