Skip to content

Commit a9f3c27

Browse files
committed
[aws][system] Add C++ dependencies images
1 parent f96df99 commit a9f3c27

File tree

6 files changed

+79
-4
lines changed

6 files changed

+79
-4
lines changed

config/systems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@
6262
"uuid": "3.4.0"
6363
}
6464
}
65+
},
66+
"cpp": {
67+
"base_images": {
68+
"all": "amazon/aws-lambda-provided:al2.2022.04.27.09"
69+
},
70+
"dependencies": [
71+
"sdk", "boost", "hiredis"
72+
],
73+
"versions": ["all"],
74+
"images": ["build"]
6575
}
6676
}
6777
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE} as builder
3+
ARG WORKERS
4+
ENV WORKERS=${WORKERS}
5+
6+
7+
RUN yum install -y cmake curl libcurl libcurl-devel git gcc gcc-c++ make tar gzip which python-devel
8+
RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz\
9+
&& tar -xf boost_1_79_0.tar.gz && cd boost_1_79_0\
10+
&& echo "using gcc : : $(which gcc10-c++) ;" >> tools/build/src/user-config.jam\
11+
&& ./bootstrap.sh --prefix=/opt\
12+
&& ./b2 -j${WORKERS} --prefix=/opt cxxflags="-fPIC" link=static install
13+
#RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz\
14+
# && tar -xf boost_1_79_0.tar.gz && cd boost_1_79_0 && ./bootstrap.sh --prefix=/opt\
15+
# && ./b2 -j${WORKERS} --prefix=/opt cxxflags="-fPIC" link=static install
16+
17+
FROM ${BASE_IMAGE}
18+
19+
COPY --from=builder /opt /opt
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE} as builder
3+
ARG WORKERS
4+
ENV WORKERS=${WORKERS}
5+
6+
RUN yum install -y git make gcc gcc-c++
7+
RUN git clone https://github.com/redis/hiredis.git && cd hiredis\
8+
&& PREFIX=/opt make -j${WORKERS} install
9+
10+
FROM ${BASE_IMAGE}
11+
12+
COPY --from=builder /opt /opt
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE} as builder
3+
ARG WORKERS
4+
ENV WORKERS=${WORKERS}
5+
6+
7+
RUN apt-get update && apt-get install -y cmake build-essential curl libcurl4-openssl-dev openssl libssl-dev git zlib1g zlib1g-dev && update-ca-certificates
8+
RUN git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git\
9+
&& cd aws-sdk-cpp && mkdir build && cd build\
10+
&& cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="s3;dynamodb;sqs" -DBUILD_SHARED_LIBS="off" -DENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/opt/ ..\
11+
&& cmake --build . --parallel ${WORKERS}\
12+
&& cmake --install .
13+
14+
FROM ${BASE_IMAGE}
15+
16+
COPY --from=builder /opt /opt

docker/aws/python/Dockerfile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG VERSION
44
ENV PYTHON_VERSION=${VERSION}
55

66
# useradd, groupmod
7-
RUN yum install -y shadow-utils
7+
RUN yum install -y cmake curl libcurl libcurl-devel
88
ENV GOSU_VERSION 1.14
99
# https://github.com/tianon/gosu/releases/tag/1.14
1010
# key https://keys.openpgp.org/search?q=tianon%40debian.org

tools/build_docker_images.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
parser.add_argument(
1313
"--deployment", default=None, choices=["local", "aws", "azure", "gcp"], action="store"
1414
)
15-
parser.add_argument("--type", default=None, choices=["build", "run", "manage"], action="store")
16-
parser.add_argument("--language", default=None, choices=["python", "nodejs"], action="store")
15+
parser.add_argument("--type", default=None, choices=["build", "dependencies", "run", "manage"], action="store")
16+
parser.add_argument("--type-tag", default=None, type=str, action="store")
17+
parser.add_argument("--language", default=None, choices=["python", "nodejs", "cpp"], action="store")
18+
parser.add_argument('--parallel', default=1, type=int, action='store')
1719
args = parser.parse_args()
1820
config = json.load(open(os.path.join(PROJECT_DIR, "config", "systems.json"), "r"))
1921
client = docker.from_env()
@@ -40,6 +42,7 @@ def build(image_type, system, language=None, version=None, version_name=None):
4042
# if we pass an integer, the build will fail with 'connection reset by peer'
4143
buildargs = {
4244
"VERSION": version,
45+
'WORKERS': str(args.parallel)
4346
}
4447
if version:
4548
buildargs["BASE_IMAGE"] = version_name
@@ -50,7 +53,6 @@ def build(image_type, system, language=None, version=None, version_name=None):
5053
)
5154
client.images.build(path=PROJECT_DIR, dockerfile=dockerfile, buildargs=buildargs, tag=target)
5255

53-
5456
def build_language(system, language, language_config):
5557
configs = []
5658
if "base_images" in language_config:
@@ -74,6 +76,22 @@ def build_systems(system, system_config):
7476
build(args.type, system)
7577
else:
7678
print(f"Skipping manage image for {system}")
79+
elif args.type == "dependencies":
80+
if args.language:
81+
if "dependencies" in system_config["languages"][args.language]:
82+
language_config = system_config["languages"][args.language]
83+
# for all dependencies
84+
if args.type_tag:
85+
# for all image versions
86+
for version, base_image in language_config["base_images"].items():
87+
build(f"{args.type}.{args.type_tag}", system, args.language, version, base_image)
88+
else:
89+
for dep in system_config["languages"][args.language]["dependencies"]:
90+
# for all image versions
91+
for version, base_image in language_config["base_images"].items():
92+
build(f"{args.type}.{dep}", system, args.language, version, base_image)
93+
else:
94+
raise RuntimeError('Language must be specified for dependencies')
7795
else:
7896
if args.language:
7997
build_language(system, args.language, system_config["languages"][args.language])

0 commit comments

Comments
 (0)