#
# Dockerfile for CI and Flexpart container images
# Options:
#	- COMMIT = ... (use git log --pretty=format:'%h %D (%s %at)' -n 1)
#			   with this option Flexpart is build inside the container
# Build Examples:
#	- podman build -t harbor.wolke.img.univie.ac.at/flexpart/flexpartv11:$(git rev-parse --abbrev-ref HEAD) -f Dockerfile_flexpart --build-arg COMMIT="$(git log --pretty=format:'%h %D %ad' -n 1)"
#
#
# Build image with Flexpart inside
#
#FROM harbor.wolke.img.univie.ac.at/flexpart/almalinux8:latest
FROM harbor.wolke.img.univie.ac.at/flexpart/rockylinux9:latest
ARG COMMIT=0
ENV COMMIT=$COMMIT
COPY ./src /src
COPY ./tests/default_options /options
COPY ./tests/default_winds /inputs
COPY ./entrypoint.sh /entrypoint.sh
WORKDIR /src
#
# compile using a standardized 
# need to fix march to x86_64_v3 , remove mtune
# here generic means core_avx2
RUN make -f makefile_gfortran eta=no arch=generic \
	&& make -f makefile_gfortran arch=generic \
	&& mkdir -p /output \
	&& echo -e "/options/\n/output/\n/inputs/\n/inputs/AVAILABLE" > /pathnames
# In the Dockerfile, the ENTRYPOINT command defines the executable, 
# while CMD sets the default parameter. 
# so here our entrypoint run script and default FLEXPART_ETA or FLEXPART
ENTRYPOINT ["/entrypoint.sh"]
CMD ["FLEXPART_ETA"]
