Skip to content

Commit

Permalink
Switch Docker base image from Ubuntu 18.10 to Debian 10
Browse files Browse the repository at this point in the history
Closes: #4
  • Loading branch information
ypid committed Feb 9, 2021
1 parent 56ad0d2 commit 262c6b6
Show file tree
Hide file tree
Showing 9 changed files with 1,399 additions and 1,214 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build/*
config/keys/*
config/env/*
config/container/Dockerfile.*
config/container/Dockerfile-*
release/*
.*
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,39 @@ mrproper: storage-delete machine-delete

## Secondary Targets ##

config/container/Dockerfile: config/container/Dockerfile.j2 config/container/render_template
./config/container/render_template "$<" "{\"tags\":[]}" > "$@"

## Support for different Docker image variants.
config/container/Dockerfile-golang:
config/container/Dockerfile-latest:
config/container/Dockerfile-%: config/container/Dockerfile.j2 config/container/render_template
./config/container/render_template "$<" "{\"tags\":[\"$*\"]}" > "$@"

.PHONY: image
image:
image: config/container/Dockerfile
$(docker) build \
--tag $(IMAGE) \
--file $(PWD)/config/container/Dockerfile \
--file "$(PWD)/$<" \
$(IMAGE_OPTIONS) \
$(PWD)

config/container/Dockerfile.minimal: config/container/Dockerfile config/container/render_template
./config/container/render_template "$<" | grep -v '^#\s*$$' > "$@"

.PHONY: image-minimal
image-minimal: config/container/Dockerfile.minimal
.PHONY: image-%
image-golang:
image-latest:
image-%: config/container/Dockerfile-%
$(docker) build \
--tag $(IMAGE) \
--file "$(PWD)/$<" \
$(IMAGE_OPTIONS) \
$(PWD)

## Note that the default `image` target should be used for pinning.
.PHONY: config/container/packages-pinned.list
config/container/packages-pinned.list:
$(contain-no-tty) pin-packages > "$@"


.PHONY: tools
tools:
mkdir -p config/keys build/base release build/external
Expand Down
77 changes: 19 additions & 58 deletions config/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,30 @@
ARG GOLANG_IMAGE_REF=@sha256:84349ee862d8bafff35e0d2bfd539da565b536b4dfce654773fc21a1db2da6d7
ARG UBUNTU_IMAGE_REF=@sha256:7d657275047118bb77b052c4c0ae43e8a289ca2879ebfa78a703c93aa8fd686c

# {% if "golang" in tags %}
FROM golang${GOLANG_IMAGE_REF} as golang

ARG FIXUID_GIT_REF="0ec93d22e52bde5b7326e84cb62fd26a3d20cead"
ARG OZZOCONFIG_GIT_REF="0ff174cf5aa6480026e0b40c14fd9cfb61c4abf6"
ARG JSONPREPROCESS_GIT_REF="a4e954386171be645f1eb7c41865d2624b69259d"
ARG TOML_GIT_REF="3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005"
ARG YAMLV2_GIT_REF="51d6538a90f86fe93ac480b35f37b2be17fef232"
ARG GLIDE_GIT_REF="b94b39d657d8abcccba6545e148f1201aee6ffec"

RUN apk add bash git make

RUN printf "\
github.com/boxboat/fixuid.git github.com/boxboat/fixuid ${FIXUID_GIT_REF} \n\
github.com/go-ozzo/ozzo-config github.com/go-ozzo/ozzo-config ${OZZOCONFIG_GIT_REF} \n\
github.com/hnakamur/jsonpreprocess github.com/hnakamur/jsonpreprocess ${JSONPREPROCESS_GIT_REF} \n\
github.com/BurntSushi/toml github.com/BurntSushi/toml ${TOML_GIT_REF} \n\
github.com/go-yaml/yaml gopkg.in/yaml.v2 ${YAMLV2_GIT_REF} \n" \
> /go/src/repos

RUN echo ' \
set -o nounset -o pipefail -o errexit; \
cat /go/src/repos | while read -r line; do \
repo=$(echo $line | awk "{ print \$1 }"); \
folder=$(echo $line | awk "{ print \$2 }"); \
ref=$(echo $line | awk "{ print \$3 }"); \
git clone "https://${repo}" "/go/src/${folder}"; \
git -C "/go/src/${folder}" checkout ${ref}; \
done' \
| bash

RUN go build -o /usr/local/bin/fixuid github.com/boxboat/fixuid
# {% endif %}


FROM ubuntu:cosmic${UBUNTU_IMAGE_REF}

# {% if "golang" in tags %}
COPY --from=golang /usr/local/bin/ /usr/local/bin/
# {% endif %}
# This file was generated using a Jinja2 template.
# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's.

ARG DEBIAN_IMAGE_REF=@sha256:8414aa82208bc4c2761dc149df67e25c6b8a9380e5d8c4e7b5c84ca2d04bb244



FROM debian:buster${DEBIAN_IMAGE_REF}

ARG DEBIAN_FRONTEND=noninteractive


ENV HOME=/home/build
ENV PATH=/home/build/scripts:/opt/aosp-build/scripts:/home/build/out/host/linux-x86/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
ENV LANG=C.UTF-8 \
TZ=UTC \
TERM=xterm-256color

## The list can be generated by: dpkg -l | awk '{ if ($1 == "ii") print $2 "=" $3 }'
ADD config/container/packages.list /etc/apt/packages.list

ADD config/container/sources.list /etc/apt/sources.list
RUN apt update -y \
&& apt install -y $(cat /etc/apt/packages.list) \
ADD config/container/packages-pinned.list /etc/apt/packages.list

RUN apt-get update \
&& apt-get install -y $(grep -v '^#' /etc/apt/packages.list) \
&& sed --in-place '/en_US.UTF-8/s/^#\s*//;' /etc/locale.gen \
&& dpkg-reconfigure locales \
&& update-locale LANG=en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ADD config /opt/aosp-build/config
Expand All @@ -65,14 +34,6 @@ RUN useradd -G plugdev,sudo -ms /bin/bash build \
&& chown -R build:build /home/build \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# {% if "golang" in tags %}
RUN chown root:root /usr/local/bin/fixuid \
&& chmod 4755 /usr/local/bin/fixuid \
&& mkdir -p /etc/fixuid \
&& printf "user: build\ngroup: build\npaths:\n - /\n - /home/build/build\n" > /etc/fixuid/config.yml

ENTRYPOINT ["/usr/local/bin/fixuid", "-q"]
# {% endif %}

WORKDIR /home/build

Expand Down
93 changes: 93 additions & 0 deletions config/container/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{{ "# This file was generated using a Jinja2 template." }}
{{ "# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's." }}

{% if "golang" in tags %}
ARG GOLANG_IMAGE_REF=@sha256:84349ee862d8bafff35e0d2bfd539da565b536b4dfce654773fc21a1db2da6d7
{% endif %}
ARG DEBIAN_IMAGE_REF=@sha256:8414aa82208bc4c2761dc149df67e25c6b8a9380e5d8c4e7b5c84ca2d04bb244

{% if "golang" in tags %}
FROM golang${GOLANG_IMAGE_REF} as golang

ARG FIXUID_GIT_REF="0ec93d22e52bde5b7326e84cb62fd26a3d20cead"
ARG OZZOCONFIG_GIT_REF="0ff174cf5aa6480026e0b40c14fd9cfb61c4abf6"
ARG JSONPREPROCESS_GIT_REF="a4e954386171be645f1eb7c41865d2624b69259d"
ARG TOML_GIT_REF="3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005"
ARG YAMLV2_GIT_REF="51d6538a90f86fe93ac480b35f37b2be17fef232"
ARG GLIDE_GIT_REF="b94b39d657d8abcccba6545e148f1201aee6ffec"

RUN apk add bash git make

RUN printf "\
github.com/boxboat/fixuid.git github.com/boxboat/fixuid ${FIXUID_GIT_REF} \n\
github.com/go-ozzo/ozzo-config github.com/go-ozzo/ozzo-config ${OZZOCONFIG_GIT_REF} \n\
github.com/hnakamur/jsonpreprocess github.com/hnakamur/jsonpreprocess ${JSONPREPROCESS_GIT_REF} \n\
github.com/BurntSushi/toml github.com/BurntSushi/toml ${TOML_GIT_REF} \n\
github.com/go-yaml/yaml gopkg.in/yaml.v2 ${YAMLV2_GIT_REF} \n" \
> /go/src/repos

RUN echo ' \
set -o nounset -o pipefail -o errexit; \
cat /go/src/repos | while read -r line; do \
repo=$(echo $line | awk "{ print \$1 }"); \
folder=$(echo $line | awk "{ print \$2 }"); \
ref=$(echo $line | awk "{ print \$3 }"); \
git clone "https://${repo}" "/go/src/${folder}"; \
git -C "/go/src/${folder}" checkout ${ref}; \
done' \
| bash

RUN go build -o /usr/local/bin/fixuid github.com/boxboat/fixuid
{% endif %}


FROM debian:buster${DEBIAN_IMAGE_REF}

ARG DEBIAN_FRONTEND=noninteractive

{% if "golang" in tags %}
COPY --from=golang /usr/local/bin/ /usr/local/bin/
{% endif %}

ENV HOME=/home/build
ENV PATH=/home/build/scripts:/opt/aosp-build/scripts:/home/build/out/host/linux-x86/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

ENV LANG=C.UTF-8 \
TZ=UTC \
TERM=xterm-256color

ADD config/container/sources.list /etc/apt/sources.list
{% if "latest" in tags %}
ADD config/container/packages.list /etc/apt/packages.list
{% else %}
ADD config/container/packages-pinned.list /etc/apt/packages.list
{% endif %}

RUN apt-get update \
&& apt-get install -y $(grep -v '^#' /etc/apt/packages.list) \
&& sed --in-place '/en_US.UTF-8/s/^#\s*//;' /etc/locale.gen \
&& dpkg-reconfigure locales \
&& update-locale LANG=en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ADD config /opt/aosp-build/config
ADD scripts /opt/aosp-build/scripts

RUN useradd -G plugdev,sudo -ms /bin/bash build \
&& chown -R build:build /home/build \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

{% if "golang" in tags %}
RUN chown root:root /usr/local/bin/fixuid \
&& chmod 4755 /usr/local/bin/fixuid \
&& mkdir -p /etc/fixuid \
&& printf "user: build\ngroup: build\npaths:\n - /\n - /home/build/build\n" > /etc/fixuid/config.yml

ENTRYPOINT ["/usr/local/bin/fixuid", "-q"]
{% endif %}

WORKDIR /home/build

CMD [ "/bin/bash", "/usr/local/bin/build" ]

USER build
Loading

0 comments on commit 262c6b6

Please sign in to comment.