generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Dockerfile.build
69 lines (58 loc) · 2.93 KB
/
Dockerfile.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# This Dockerfile defines the container in which we perform the build
# To build it, you must specify at least the following --build-arg values
# with some suggested default shown here
#
# --build-arg GRADLE_VERSION=8.10.2 - The version of Gradle you want to build with
# --build-arg AFCT_VERSION=4.0.5198 - The version of the Azure Functions Core Tools
# --build-arg JAVA_VERSION=17 - The version of the JDK (and thus JRE) you want to build against/with
#
#
# STAGE 1: This stage is responsible for things that change only when we retool our build chain and thus change very infrequently
# (and in fact, probably less than the actual builder container image). This is a small optimization that will make your life
# a tad bit easier when you are rebuilding the builder image
#
FROM alpine:3.20 AS downloader
ARG GRADLE_VERSION=8.10.2
ARG AFCT_VERSION=4.0.5198
RUN apk update && apk add wget --no-cache
# Get Gradle into /var/downloads/gradle (whithout version sub-directory
# this makes it so that the GRADLE_VERSION does not need to leak into the
# builder image below and only needs JAVA_VERSION as a build-arg
RUN mkdir -p /var/downloads/gradle
WORKDIR /var/downloads/gradle
RUN wget -o /tmp/gradle.download.log https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
RUN unzip gradle-${GRADLE_VERSION}-bin.zip
RUN mv /var/downloads/gradle/gradle-${GRADLE_VERSION}/* /var/downloads/gradle
RUN rm -r /var/downloads/gradle/gradle-${GRADLE_VERSION}/ gradle-${GRADLE_VERSION}-bin.zip
# Get Azure Functions Core Tools into /var/downloads/azure-functions
RUN mkdir -p /var/downloads/azure-functions
WORKDIR /var/downloads/azure-functions
RUN wget -o /tmp/azure.functions.download.log https://github.com/Azure/azure-functions-core-tools/releases/download/${AFCT_VERSION}/Azure.Functions.Cli.linux-x64.${AFCT_VERSION}.zip
RUN unzip Azure.Functions.Cli.linux-x64.${AFCT_VERSION}.zip 1>/tmp/azure.functions.extraction.log
RUN rm Azure.Functions.Cli.linux-x64.${AFCT_VERSION}.zip
#
# STAGE 2: Build the actual container that does the build
#
FROM ubuntu:24.04 AS builder
ARG JAVA_VERSION=17
# Latest patches
RUN apt-get update && apt-get upgrade -y
# Get the unpacked gradle binaries from the downloader stage
RUN mkdir -p /opt/gradle
COPY --from=downloader /var/downloads/gradle/ /opt/gradle/
ENV PATH "${PATH}:/opt/gradle/bin"
# Overlay the Azure Function binaries from the downloader
# cf https://github.com/Azure/azure-functions-core-tools/blob/master/README.md#linux
RUN mkdir -p /opt/azure-functions
COPY --from=downloader /var/downloads/azure-functions/ /opt/azure-functions/
RUN chmod +x /opt/azure-functions/func /opt/azure-functions/gozip
ENV PATH "${PATH}:/opt/azure-functions/"
ENV FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT 1
# Install pre-requisites
RUN apt-get clean \
&& apt-get --allow-releaseinfo-change update \
&& apt-get --yes install openjdk-${JAVA_VERSION}-jdk
# A place to mount our source
RUN mkdir -p "/src"
WORKDIR "/src"