Separate dockerfiles for more efficient build
Change-Id: I526f4317ada36d1ac24d904d3ffb873611c0225c
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 4e91942..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Copyright 2019-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu:16.04 AS base-builder
-RUN apt-get update && apt-get install -y \
- sudo \
- linux-headers-`uname -r` \
- vim-common \
- git \
- build-essential \
- cmake \
- && rm -rf /var/lib/apt/lists/*
-RUN git clone https://gitlab.eurecom.fr/oai/openairinterface5g/ /openairinterface5g
-WORKDIR /openairinterface5g
-ENV USER=root
-RUN git checkout -f v1.0.0 && \
- /bin/bash -c "source oaienv" && \
- cd cmake_targets && \
- ./build_oai -I
-
-FROM base-builder AS enb-builder
-WORKDIR /openairinterface5g
-ENV USER=root
-RUN /bin/bash -c "source oaienv" && \
- cd cmake_targets && \
- ./build_oai --eNB -t ETHERNET -c
-
-FROM ubuntu:16.04 AS lte-softmodem
-RUN apt-get update && apt-get install -y \
- libssl1.0.0 \
- libnettle6 \
- libsctp1 \
- libforms2 \
- libprotobuf-c1 \
- libyaml-0-2 \
- libconfig9 \
- dnsutils \
- iproute2 \
- iputils-ping \
- && rm -rf /var/lib/apt/lists/*
-WORKDIR /openairinterface5g/cmake_targets
-COPY --from=enb-builder /openairinterface5g/cmake_targets/ .
-
-FROM base-builder AS ue-builder
-WORKDIR /openairinterface5g
-ENV USER=root
-RUN /bin/bash -c "source oaienv" && \
- cd cmake_targets && \
- ./build_oai --UE -t ETHERNET -c
-
-FROM ubuntu:16.04 AS lte-uesoftmodem
-RUN apt-get update && apt-get install -y \
- libssl1.0.0 \
- libnettle6 \
- libsctp1 \
- libforms2 \
- libconfig9 \
- libblas3 \
- liblapacke \
- sudo \
- dnsutils \
- iproute2 \
- iputils-ping \
- net-tools \
- && rm -rf /var/lib/apt/lists/*
-WORKDIR /openairinterface5g/cmake_targets
-COPY --from=ue-builder /openairinterface5g/cmake_targets .
-COPY --from=ue-builder /openairinterface5g/targets/bin/nvram .
-COPY --from=ue-builder /openairinterface5g/targets/bin/usim .
-COPY --from=ue-builder /openairinterface5g/targets ../targets
diff --git a/Dockerfile.base b/Dockerfile.base
new file mode 100644
index 0000000..4954883
--- /dev/null
+++ b/Dockerfile.base
@@ -0,0 +1,42 @@
+#
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu:16.04 AS oai-base
+RUN apt-get update && apt-get install -y \
+ sudo \
+ vim-common \
+ git \
+ build-essential \
+ cmake \
+ && rm -rf /var/lib/apt/lists/*
+RUN git clone https://gitlab.eurecom.fr/oai/openairinterface5g/ /openairinterface5g -b v1.0.0
+
+WORKDIR /openairinterface5g
+ENV USER=root
+RUN /bin/bash -c "source oaienv" && cd cmake_targets && ./build_oai -I
+
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+
+LABEL org.label-schema.schema-version=1.0 \
+ org.label-schema.name=oai-base \
+ org.label-schema.version=$org_label_schema_version \
+ org.label-schema.vcs-url=$org_label_schema_vcs_url \
+ org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+ org.label-schema.build-date=$org_label_schema_build_date \
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
diff --git a/Dockerfile.enb b/Dockerfile.enb
new file mode 100644
index 0000000..dc3503e
--- /dev/null
+++ b/Dockerfile.enb
@@ -0,0 +1,53 @@
+#
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ARG build_base
+
+FROM $build_base AS enb-builder
+WORKDIR /openairinterface5g
+ENV USER=root
+RUN /bin/bash -c "source oaienv" && cd cmake_targets && ./build_oai --eNB -t ETHERNET -c
+
+FROM ubuntu:16.04 AS lte-softmodem
+RUN apt-get update && apt-get install -y \
+ libssl1.0.0 \
+ libnettle6 \
+ libsctp1 \
+ libforms2 \
+ libprotobuf-c1 \
+ libyaml-0-2 \
+ libconfig9 \
+ dnsutils \
+ iproute2 \
+ iputils-ping \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /openairinterface5g/cmake_targets
+COPY --from=enb-builder /openairinterface5g/cmake_targets/ .
+
+# Label image
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+
+LABEL org.label-schema.schema-version=1.0 \
+ org.label-schema.name=lte-softmodem \
+ org.label-schema.version=$org_label_schema_version \
+ org.label-schema.vcs-url=$org_label_schema_vcs_url \
+ org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+ org.label-schema.build-date=$org_label_schema_build_date \
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
diff --git a/Dockerfile.ue b/Dockerfile.ue
new file mode 100644
index 0000000..d2e3a0b
--- /dev/null
+++ b/Dockerfile.ue
@@ -0,0 +1,62 @@
+#
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ARG build_base
+
+FROM $build_base AS ue-builder
+RUN apt-get update && apt-get install -y \
+ linux-headers-`uname -r` \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /openairinterface5g
+ENV USER=root
+RUN /bin/bash -c "source oaienv" && cd cmake_targets && ./build_oai --UE -t ETHERNET -c
+
+FROM ubuntu:16.04 AS lte-uesoftmodem
+RUN apt-get update && apt-get install -y \
+ libssl1.0.0 \
+ libnettle6 \
+ libsctp1 \
+ libforms2 \
+ libconfig9 \
+ libblas3 \
+ liblapacke \
+ sudo \
+ dnsutils \
+ iproute2 \
+ iputils-ping \
+ net-tools \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /openairinterface5g/cmake_targets
+COPY --from=ue-builder /openairinterface5g/cmake_targets .
+COPY --from=ue-builder /openairinterface5g/targets/bin/nvram .
+COPY --from=ue-builder /openairinterface5g/targets/bin/usim .
+COPY --from=ue-builder /openairinterface5g/targets ../targets
+
+# Label image
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+
+LABEL org.label-schema.schema-version=1.0 \
+ org.label-schema.name=lte-uesoftmodem \
+ org.label-schema.version=$org_label_schema_version \
+ org.label-schema.vcs-url=$org_label_schema_vcs_url \
+ org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+ org.label-schema.build-date=$org_label_schema_build_date \
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
diff --git a/Makefile b/Makefile
index 11e9f1d..3d7f3bf 100644
--- a/Makefile
+++ b/Makefile
@@ -15,15 +15,18 @@
#
VERSION ?= $(shell cat ./VERSION)
-ENB_NAME ?= lte-softmodem
+BASE_NAME ?= oai-base
UE_NAME ?= lte-uesoftmodem
+ENB_NAME ?= lte-softmodem
-DOCKER_TAG ?= ${VERSION}
+# Tag is fixed to OAI release version, v1.0.0, regardless of VERSION file
+DOCKER_TAG ?= 1.0.0
DOCKER_REGISTRY ?=
DOCKER_REPOSITORY ?=
DOCKER_BUILD_ARGS ?=
-ENB_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${ENB_NAME}:${DOCKER_TAG}
+BASE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${BASE_NAME}:${DOCKER_TAG}
UE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${UE_NAME}:${DOCKER_TAG}
+ENB_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${ENB_NAME}:${DOCKER_TAG}
## Docker labels. Only set ref and commit date if committed
DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
@@ -34,8 +37,9 @@
# https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target
docker-build:
docker build $(DOCKER_BUILD_ARGS) \
- --target ${ENB_NAME} \
- --tag ${ENB_IMAGENAME} \
+ --target ${BASE_NAME} \
+ --tag ${BASE_IMAGENAME} \
+ --file Dockerfile.base \
--build-arg org_label_schema_version="${VERSION}" \
--build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
--build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
@@ -45,6 +49,19 @@
docker build $(DOCKER_BUILD_ARGS) \
--target ${UE_NAME} \
--tag ${UE_IMAGENAME} \
+ --file Dockerfile.ue \
+ --build-arg build_base=${BASE_IMAGENAME} \
+ --build-arg org_label_schema_version="${VERSION}" \
+ --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
+ --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
+ --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
+ --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
+ .
+ docker build $(DOCKER_BUILD_ARGS) \
+ --target ${ENB_NAME} \
+ --tag ${ENB_IMAGENAME} \
+ --file Dockerfile.enb \
+ --build-arg build_base=${BASE_IMAGENAME} \
--build-arg org_label_schema_version="${VERSION}" \
--build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
--build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
@@ -53,8 +70,9 @@
.
docker-push:
- docker push ${ENB_IMAGENAME}
+ docker push ${BASE_IMAGENAME}
docker push ${UE_IMAGENAME}
+ docker push ${ENB_IMAGENAME}
test: docker-build
diff --git a/VERSION b/VERSION
index 3eefcb9..7dea76e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+1.0.1