Dockerfile 5.76 KB
Newer Older
Romain Hunault's avatar
Romain Hunault committed
1
FROM ubuntu:20.04
Romain Hunault's avatar
Romain Hunault committed
2
MAINTAINER Romain Hunault <romain.hunault@e.email>
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
3
4
5
6
7
8

# Environment variables
#######################

ENV SRC_DIR /srv/src
ENV CCACHE_DIR /srv/ccache
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
9
ENV ZIP_DIR /srv/zips
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
10
ENV LMANIFEST_DIR /srv/local_manifests
Nicola Corna's avatar
Nicola Corna committed
11
ENV KEYS_DIR /srv/keys
Nicola Corna's avatar
Nicola Corna committed
12
ENV LOGS_DIR /srv/logs
Nicola Corna's avatar
Nicola Corna committed
13
ENV USERSCRIPTS_DIR /srv/userscripts
Nicola Corna's avatar
Nicola Corna committed
14

Nicola Corna's avatar
Nicola Corna committed
15
16
ENV DEBIAN_FRONTEND noninteractive
ENV USER root
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
17
18
19
20
21
22
23
24

# Configurable environment variables
####################################

# By default we want to use CCACHE, you can disable this
# WARNING: disabling this may slow down a lot your builds!
ENV USE_CCACHE 1

25
26
27
28
29
# ccache maximum size. It should be a number followed by an optional suffix: k,
# M, G, T (decimal), Ki, Mi, Gi or Ti (binary). The default suffix is G. Use 0
# for no limit.
ENV CCACHE_SIZE 50G

Romain Hunault's avatar
Romain Hunault committed
30
31
32
# We need to specify the ccache binary since it is no longer packaged along with AOSP
ENV CCACHE_EXEC /usr/bin/ccache

Romain Hunault's avatar
Romain Hunault committed
33
# Environment for the /e/ branches name
34
# See https://github.com/LineageOS/android_vendor_cm/branches for possible options
Romain Hunault's avatar
Romain Hunault committed
35
ENV BRANCH_NAME 'v1-q'
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
36

Romain Hunault's avatar
Romain Hunault committed
37
38
39
# Environment for the device
# eg. DEVICE=hammerhead
ENV DEVICE ''
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
40

Nicola Corna's avatar
Nicola Corna committed
41
42
43
# Release type string
ENV RELEASE_TYPE 'UNOFFICIAL'

Romain Hunault's avatar
Romain Hunault committed
44
# Repo use for build
Romain Hunault's avatar
Romain Hunault committed
45
ENV REPO 'https://gitlab.e.foundation/e/os/android.git'
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
46

Micha M's avatar
Micha M committed
47
48
49
50
# Optional parameter to repo init --depth N
# A size of 0 deactivates --depth N
ENV REPO_INIT_DEPTH 0

Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
51
# User identity
Romain Hunault's avatar
Romain Hunault committed
52
53
ENV USER_NAME '/e/ robot'
ENV USER_MAIL 'erobot@e.email'
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
54

Romain Hunault's avatar
Romain Hunault committed
55
# Include proprietary files, downloaded automatically from github.com/TheMuppets/ and gitlab.com/the-muppets/
Nicola Corna's avatar
Nicola Corna committed
56
57
58
# Only some branches are supported
ENV INCLUDE_PROPRIETARY true

Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
59
# If you want to preserve old ZIPs set this to 'false'
Nicola Corna's avatar
Nicola Corna committed
60
ENV CLEAN_OUTDIR false
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
61
62

# Change this cron rule to what fits best for you
Nicola Corna's avatar
Nicola Corna committed
63
# Use 'now' to start the build immediately
Nicola Corna's avatar
Nicola Corna committed
64
65
# For example, '0 10 * * *' means 'Every day at 10:00 UTC'
ENV CRONTAB_TIME 'now'
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
66

Nicola Corna's avatar
Nicola Corna committed
67
68
69
# Clean artifacts output after each build
ENV CLEAN_AFTER_BUILD true

70
71
72
# Provide a default JACK configuration in order to avoid out-of-memory issues
ENV ANDROID_JACK_VM_ARGS "-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"

Nicola Corna's avatar
Nicola Corna committed
73
74
75
# Custom packages to be installed
ENV CUSTOM_PACKAGES ''

76
# Sign the builds with the keys in $KEYS_DIR
Nicola Corna's avatar
Nicola Corna committed
77
ENV SIGN_BUILDS false
Nicola Corna's avatar
Nicola Corna committed
78

79
80
81
# When SIGN_BUILDS = true but no keys have been provided, generate a new set with this subject
ENV KEYS_SUBJECT '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'

Nicola Corna's avatar
Nicola Corna committed
82
# Move the resulting zips to $ZIP_DIR/$codename instead of $ZIP_DIR/
Nicola Corna's avatar
Nicola Corna committed
83
ENV ZIP_SUBDIR true
Nicola Corna's avatar
Nicola Corna committed
84

Nicola Corna's avatar
Nicola Corna committed
85
86
87
# Write the verbose logs to $LOGS_DIR/$codename instead of $LOGS_DIR/
ENV LOGS_SUBDIR true

Romain Hunault's avatar
Romain Hunault committed
88
89
90
# Backup the .img in addition to zips
ENV BACKUP_IMG false

91
92
93
# Delete old zips in $ZIP_DIR, keep only the N latest one (0 to disable)
ENV DELETE_OLD_ZIPS 0

Nicola Corna's avatar
Nicola Corna committed
94
95
96
# Delete old logs in $LOGS_DIR, keep only the N latest one (0 to disable)
ENV DELETE_OLD_LOGS 0

Sumit Pundir's avatar
Sumit Pundir committed
97
98
99
# Save recovery image
ENV RECOVERY_IMG false

Sumit Pundir's avatar
Sumit Pundir committed
100
101
102
# Ship with Minimal Apps
ENV MINIMAL_APPS false

Alexandre Roux's avatar
Alexandre Roux committed
103
104
105
# Force an eng build even when device name doesn't contain -eng
ENV ENG_BUILD false

106
107
108
#Save intermediate system.img even when not in out folder
ENV BACKUP_INTERMEDIATE_SYSTEM_IMG false

Romain Hunault's avatar
Romain Hunault committed
109
110
111
112
113
114
# Backup emulator files
ENV BACKUP_EMULATOR false

# Use lunch command (by default, it's brunch)
ENV USE_LUNCH false

Alexandre Roux's avatar
Alexandre Roux committed
115

Nicola Corna's avatar
Nicola Corna committed
116
117
118
# You can optionally specify a USERSCRIPTS_DIR volume containing these scripts:
#  * begin.sh, run at the very beginning
#  * before.sh, run after the syncing and patching, before starting the builds
Romain Hunault's avatar
Romain Hunault committed
119
#  * pre-build.sh, run before the build of every device
Nicola Corna's avatar
Nicola Corna committed
120
121
122
123
124
#  * post-build.sh, run after the build of every device
#  * end.sh, run at the very end
# Each script will be run in $SRC_DIR and must be owned and writeable only by
# root

Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
125
126
127
128
# Create Volume entry points
############################
VOLUME $SRC_DIR
VOLUME $CCACHE_DIR
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
129
VOLUME $ZIP_DIR
130
VOLUME $LMANIFEST_DIR
Nicola Corna's avatar
Nicola Corna committed
131
VOLUME $KEYS_DIR
Nicola Corna's avatar
Nicola Corna committed
132
VOLUME $LOGS_DIR
Nicola Corna's avatar
Nicola Corna committed
133
VOLUME $USERSCRIPTS_DIR
Romain Hunault's avatar
Romain Hunault committed
134
VOLUME /root/.ssh
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
135

Nicola Corna's avatar
Nicola Corna committed
136
# Copy required files
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
137
#####################
138
COPY src/ /root/
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
139
140
141
142
143

# Create missing directories
############################
RUN mkdir -p $SRC_DIR
RUN mkdir -p $CCACHE_DIR
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
144
RUN mkdir -p $ZIP_DIR
145
RUN mkdir -p $LMANIFEST_DIR
Nicola Corna's avatar
Nicola Corna committed
146
RUN mkdir -p $KEYS_DIR
Nicola Corna's avatar
Nicola Corna committed
147
RUN mkdir -p $LOGS_DIR
Nicola Corna's avatar
Nicola Corna committed
148
RUN mkdir -p $USERSCRIPTS_DIR
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
149

Nicola Corna's avatar
Nicola Corna committed
150
151
152
153
# Install build dependencies
############################
RUN apt-get -qq update
RUN apt-get -qqy upgrade
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
154

Romain Hunault's avatar
Romain Hunault committed
155
RUN apt-get install -y bc bison bsdmainutils build-essential ccache cgpt clang cron \
Alexandre Roux's avatar
Alexandre Roux committed
156
      curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick kmod \
Romain Hunault's avatar
Romain Hunault committed
157
      lib32ncurses5-dev libncurses5 lib32readline-dev lib32z1-dev libtinfo5 liblz4-tool \
Romain Hunault's avatar
Romain Hunault committed
158
      libncurses5-dev libsdl1.2-dev libssl-dev libxml2 \
Alexandre Roux's avatar
Alexandre Roux committed
159
      libxml2-utils lsof lzop maven openjdk-8-jdk pngcrush \
160
      procps python python3 rsync schedtool squashfs-tools software-properties-common wget xdelta3 xsltproc xxd yasm \
Nicola Corna's avatar
Nicola Corna committed
161
      zip zlib1g-dev
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
162

Nicola Corna's avatar
Nicola Corna committed
163
164
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo
RUN chmod a+x /usr/local/bin/repo
Romain Hunault's avatar
Romain Hunault committed
165
166
167
168
169
RUN ln -fs /usr/bin/python3 /usr/bin/python

# Use adoptopenjdk.net to be able to use OpeJDK8 on debian:buster
RUN curl -q https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add -
RUN add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
Romain Hunault's avatar
Romain Hunault committed
170
RUN apt-get -qq update && apt-get install -y adoptopenjdk-8-hotspot=8u282-b08-3
Romain Hunault's avatar
Romain Hunault committed
171
RUN update-alternatives --set java /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
172

Alexandre Roux's avatar
Alexandre Roux committed
173
174
175
176
177
178

# Fix jack server SSL issue during build for openjdk (adoptopenjdk won't work for nougat and oreo)
RUN perl -0777 -i -p -e 's/(jdk.tls.disabledAlgorithms=.*?), TLSv1, TLSv1\.1/$1/g' \
      /etc/java-8-openjdk/security/java.security


Nicola Corna's avatar
Nicola Corna committed
179
180
181
182
# Set the work directory
########################
WORKDIR $SRC_DIR

Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
183
184
# Allow redirection of stdout to docker logs
############################################
Nicola Corna's avatar
Nicola Corna committed
185
RUN ln -sf /proc/1/fd/1 /var/log/docker.log
Julian Xhokaxhiu's avatar
Julian Xhokaxhiu committed
186
187

# Set the entry point to init.sh
Nicola Corna's avatar
Nicola Corna committed
188
################################
Nicola Corna's avatar
Nicola Corna committed
189
ENTRYPOINT /root/init.sh