Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 2196 update dockerfile #2249

Merged
merged 10 commits into from
Sep 8, 2022
2 changes: 1 addition & 1 deletion .github/jobs/build_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CMD_LOGFILE=${GITHUB_WORKSPACE}/docker_build.log
time_command docker build -t ${DOCKERHUB_TAG} \
--build-arg SOURCE_BRANCH \
--build-arg MET_BASE_REPO \
--build-arg MET_BASE_IMAGE \
--build-arg MET_BASE_TAG \
-f $DOCKERFILE_PATH ${GITHUB_WORKSPACE}
if [ $? != 0 ]; then
cat ${GITHUB_WORKSPACE}/docker_build.log
Expand Down
6 changes: 3 additions & 3 deletions .github/jobs/set_job_controls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run_unit_tests=false
run_diff=false
run_update_truth=false
met_base_repo=met-base
met_base_image=v1.0
met_base_tag=v1.1
input_data_version=develop
truth_data_version=develop

Expand Down Expand Up @@ -114,7 +114,7 @@ echo ::set-output name=run_unit_tests::$run_unit_tests
echo ::set-output name=run_diff::$run_diff
echo ::set-output name=run_update_truth::$run_update_truth
echo ::set-output name=met_base_repo::$met_base_repo
echo ::set-output name=met_base_image::$met_base_image
echo ::set-output name=met_base_tag::$met_base_tag
echo ::set-output name=input_data_version::$input_data_version
echo ::set-output name=truth_data_version::$truth_data_version

Expand All @@ -124,7 +124,7 @@ echo run_unit_tests: $run_unit_tests
echo run_diff: $run_diff
echo run_update_truth: $run_update_truth
echo met_base_repo: $met_base_repo
echo met_base_image: $met_base_image
echo met_base_tag: $met_base_tag
echo input_data_version: $input_data_version
echo truth_data_version: $truth_data_version

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_docker_and_trigger_metplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
env:
SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }}-lite
MET_BASE_REPO: met-base
MET_BASE_IMAGE: v1.0
MET_BASE_TAG: v1.1

- name: Push Docker Image
run: .github/jobs/push_docker_image.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run_diff: ${{ steps.job_status.outputs.run_diff }}
run_update_truth: ${{ steps.job_status.outputs.run_update_truth }}
met_base_repo: ${{ steps.job_status.outputs.met_base_repo }}
met_base_image: ${{ steps.job_status.outputs.met_base_image }}
met_base_tag: ${{ steps.job_status.outputs.met_base_tag }}
branch_name: ${{ steps.job_status.outputs.branch_name }}
truth_data_version: ${{ steps.job_status.outputs.truth_data_version }}
input_data_version: ${{ steps.job_status.outputs.input_data_version }}
Expand All @@ -76,7 +76,7 @@ jobs:
env:
SOURCE_BRANCH: ${{ needs.job_control.outputs.branch_name }}
MET_BASE_REPO: ${{ needs.job_control.outputs.met_base_repo }}
MET_BASE_IMAGE: ${{ needs.job_control.outputs.met_base_image }}
MET_BASE_TAG: ${{ needs.job_control.outputs.met_base_tag }}

- name: Copy Docker build log into logs directory
if: always()
Expand Down
4 changes: 2 additions & 2 deletions internal/scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG MET_BASE_REPO=met-base
ARG MET_BASE_IMAGE=v1.0
ARG MET_BASE_TAG=v1.1

FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_IMAGE}
FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG}
MAINTAINER John Halley Gotway <[email protected]>

#
Expand Down
6 changes: 3 additions & 3 deletions internal/scripts/docker/Dockerfile.copy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG MET_BASE_REPO=met-base
ARG MET_BASE_IMAGE=v1.0
ARG MET_BASE_REPO=met-base-unit-test
ARG MET_BASE_TAG=v1.1

FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_IMAGE}
FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG}
MAINTAINER John Halley Gotway <[email protected]>

#
Expand Down
69 changes: 54 additions & 15 deletions internal/scripts/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,76 @@
# How to Use Dockerfiles
How to Use Dockerfiles
======================

Run all of the Docker commands from the top-level directory of the MET repository
GitHub actions are triggered for Pull Requests to the "develop" and "main_v*"
branches and for pushes to the branches "feature_*", "bugfix_*", "develop",
"develop-ref", and "main_v*" created in this repository to automatically build
images from these Dockerfiles and push them to DockerHub repositories. The
MET Docker image is used in Dockerfiles in the METplus wrappers component
repository for testing.

## Build MET from clone
Descriptions of the Dockerfiles in this directory are provided below. Sample
commands for building these Docker images locally are also provided. Please
note that these commands should be run from the top-level directory of
the MET repository.

1. The first example below shows how to manually build a MET Docker image
using code that is cloned from the
[MET GitHub repository](https://github.com/dtcenter/MET/) and using a Docker
image for the base compilation environment for MET from the
[dtcenter/met-base](https://hub.docker.com/repository/docker/dtcenter/met-base)
DockerHub repository. It uses `Dockerfile`, which checks out MET from GitHub,
compiles the specified branch or tag from source, sets a working directory,
downloads and installs GhostScript fonts, and deletes the MET source code for
tagged releases matching "v"*. Tagged versions of the MET Docker image are
available in the
[dtcenter/met](https://hub.docker.com/repository/docker/dtcenter/met-base)
DockerHub repository.
```
docker build -t dtcenter/met:${TAG_NAME} --build-arg SOURCE_BRANCH=${BRANCH_NAME} internal/scripts/docker
docker push dtcenter/met:${TAG_NAME}
```

where:
* TAG_NAME is the name of the DockerHub tag to create
* BRANCH_NAME is the MET branch to checkout

## Build MET from local source code with minimum requirements
* `${TAG_NAME}` is the name of the DockerHub tag to create
* `${BRANCH_NAME}` is the MET branch to checkout

2. The second example below shows how to manually build a MET Docker image
using a specified branch or tag from local source code and using a local
Docker image for the base compilation environment for MET from the
[METbaseimage](https://github.com/dtcenter/METbaseimage/)
GitHub repository. (See the
[METbaseimage README.md](https://github.com/dtcenter/METbaseimage/blob/main/README.md)
file for more information on manually creating the Docker image for the base
compilation environment.) This example uses `Dockerfile.copy`, which compiles
MET using the specified branch or tag from local source code, sets a working
directory, downloads and installs GhostScript fonts, and deletes the MET
source code for tagged releases matching "v"*.
```
docker build -t dtcenter/met:${TAG_NAME} --build-arg SOURCE_BRANCH=${BRANCH_NAME} -f internal/scripts/docker/Dockerfile.copy .
docker push dtcenter/met:${TAG_NAME}
```

where:
* TAG_NAME is the name of the DockerHub tag to create
* BRANCH_NAME is the identifier to use for $MET_GIT_NAME inside image

## Build MET from local source code with unit test requirements
* `${TAG_NAME}` is the name of the DockerHub tag to create
* `${BRANCH_NAME}` is the identifier to use for $MET_GIT_NAME inside image

3. The third example below shows how to manually build a MET Docker image
using a specified branch or tag from local source code and using a local
Docker image for the base compilation environment along with the additional
packages required for running the MET unit tests from the
[METbaseimage](https://github.com/dtcenter/METbaseimage/)
GitHub repository. (See the
[METbaseimage README.md](https://github.com/dtcenter/METbaseimage/blob/main/README.md)
file for more information on manually creating the Docker image with the base
compilation environment and with the additional packages required for running
the MET unit tests.) This example also uses `Dockerfile.copy`, which is
described above.
```
docker build -t dtcenter/met:${TAG_NAME} --build-arg SOURCE_BRANCH=${BRANCH_NAME} --build-arg MET_BASE_IMAGE=unit_test_${MET_BASE_IMAGE_VERSION} -f internal/scripts/docker/Dockerfile.copy .
docker build -t dtcenter/met:${TAG_NAME} --build-arg SOURCE_BRANCH=${BRANCH_NAME} --build-arg MET_BASE_TAG=${MET_BASE_TAG} -f internal/scripts/docker/Dockerfile.copy .
docker push dtcenter/met:${TAG_NAME}
```

where:
* TAG_NAME is the name of the DockerHub tag to create
* BRANCH_NAME is the identifier to use for $MET_GIT_NAME inside image
* MET_BASE_IMAGE_VERSION is the METbaseimage tag version number
* `${TAG_NAME}` is the name of the DockerHub tag to create
* `${BRANCH_NAME}` is the identifier to use for $MET_GIT_NAME inside image
* `${MET_BASE_TAG}` is the version of [dtcenter/met-base-unit-test](https://hub.docker.com/repository/docker/dtcenter/met-base-unit-test) to be used
3 changes: 2 additions & 1 deletion internal/scripts/docker/build_met_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ echo "Configuring MET ${MET_GIT_NAME} and writing log file ${LOG_FILE}"
MET_HDF=/usr/local/hdf MET_HDFEOS=/usr/local/hdfeos \
MET_FREETYPEINC=/usr/include/freetype2 MET_FREETYPELIB=/usr/lib \
MET_CAIROINC=/usr/include/cairo MET_CAIROLIB=/usr/lib \
MET_PYTHON_CC='-I/usr/include/python3.6m' MET_PYTHON_LD='-lpython3.6m' > ${LOG_FILE}
MET_PYTHON_CC='-I/usr/local/include/python3.8' \
MET_PYTHON_LD='-L/usr/local/lib/python3.8/config-3.8-x86_64-linux-gnu -L/usr/local/lib/python3.8 -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -Xlinker -export-dynamic' > ${LOG_FILE}
if [ $? != 0 ]; then
exit 1
fi
Expand Down