Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to build everything inside a docker container
- Loading branch information
nicolaasuni
committed
Jun 21, 2018
1 parent
e795ca8
commit d05c86f
Showing
5 changed files
with
132 additions
and
7 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
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
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 +1 @@ | ||
2.6.4 | ||
2.6.5 |
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,58 @@ | ||
#!/bin/sh | ||
# | ||
# dockerbuild.sh | ||
# | ||
# Build the software inside a Docker container | ||
# | ||
# @author Nicola Asuni <info@tecnick.com> | ||
# ------------------------------------------------------------------------------ | ||
|
||
# NOTES: | ||
# This script requires Docker | ||
|
||
# EXAMPLE USAGE: | ||
# CVSPATH=project VENDOR=vendorname PROJECT=projectname MAKETARGET=all ./dockerbuild.sh | ||
|
||
# Get vendor and project name | ||
: ${CVSPATH:=project} | ||
: ${VENDOR:=vendor} | ||
: ${PROJECT:=project} | ||
|
||
# make target to execute | ||
: ${MAKETARGET:=all} | ||
|
||
# Name of the base development Docker image | ||
DOCKERDEV=${VENDOR}/dev_${PROJECT} | ||
|
||
# Build the base environment and keep it cached locally | ||
docker build --pull --tag ${DOCKERDEV} --file ./resources/Docker/Dockerfile.dev ./resources/Docker/ | ||
|
||
# Define the project root path | ||
PRJPATH=/root/src/${CVSPATH}/${PROJECT} | ||
|
||
# Generate a temporary Dockerfile to build and test the project | ||
# NOTE: The exit status of the RUN command is stored to be returned later, | ||
# so in case of error we can continue without interrupting this script. | ||
cat > Dockerfile.test <<- EOM | ||
FROM ${DOCKERDEV} | ||
RUN mkdir -p ${PRJPATH} | ||
ADD ./ ${PRJPATH} | ||
WORKDIR ${PRJPATH} | ||
RUN make ${MAKETARGET} || (echo \$? > target/make.exit) | ||
EOM | ||
|
||
# Define the temporary Docker image name | ||
DOCKER_IMAGE_NAME=${VENDOR}/build_${PROJECT} | ||
|
||
# Build the Docker image | ||
docker build --no-cache --tag ${DOCKER_IMAGE_NAME} --file Dockerfile.test . | ||
|
||
# Start a container using the newly created Docker image | ||
CONTAINER_ID=$(docker run -d ${DOCKER_IMAGE_NAME}) | ||
|
||
# Copy all build/test artifacts back to the host | ||
docker cp ${CONTAINER_ID}:"${PRJPATH}/target" ./ | ||
|
||
# Remove the temporary container and image | ||
docker rm -f ${CONTAINER_ID} || true | ||
docker rmi -f ${DOCKER_IMAGE_NAME} || true |
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,10 @@ | ||
# Dockerfile | ||
# | ||
# Linux development environment | ||
# | ||
# Extend the tecnickcom/alldev image defined in | ||
# https://github.com/tecnickcom/alldev | ||
# ------------------------------------------------------------------------------ | ||
|
||
FROM tecnickcom/alldev | ||
MAINTAINER info@tecnick.com |