-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
77 lines (66 loc) · 2.1 KB
/
Dockerfile
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
70
71
72
73
74
75
76
77
# syntax=docker/dockerfile:1
FROM ubuntu:jammy AS upstream
# Restate for later use
ARG REPO
# prevent interactive messages in apt install
ARG DEBIAN_FRONTEND=noninteractive
# install development tools
RUN apt-get update \
&& apt-get install -q -y --no-install-recommends \
apt-utils \
build-essential \
ccache \
clang \
clang-format \
clang-tidy \
cmake \
gdb \
git \
libsfml-dev \
libeigen3-dev \
libgtest-dev \
python3-pip \
sudo \
vim \
wget \
ssh-client \
&& rm -rf /var/lib/apt/lists/*
# copy source to install repo dependencies
WORKDIR /${REPO}
FROM upstream AS development
ARG UID
ARG GID
ARG USER
# fail build if args are missing
# hadolint ignore=SC2028
RUN if [ -z "$UID" ]; then echo '\nERROR: UID not set. Run \n\n \texport UID=$(id -u) \n\n on host before building Dockerfile.\n'; exit 1; fi
# hadolint ignore=SC2028
RUN if [ -z "$GID" ]; then echo '\nERROR: GID not set. Run \n\n \texport GID=$(id -g) \n\n on host before building Dockerfile.\n'; exit 1; fi
# hadolint ignore=SC2028
RUN if [ -z "$USER" ]; then echo '\nERROR: USER not set. Run \n\n \texport USER=$(whoami) \n\n on host before building Dockerfile.\n'; exit 1; fi
# install developer tools
RUN --mount=type=cache,target=/var/cache/apt,id=apt \
apt-get update && apt-get upgrade -y \
&& apt-get install -q -y --no-install-recommends \
clang-format \
clang-tidy \
git \
openssh-client \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN python3 -m pip install --no-cache-dir \
pre-commit==3.0.4
# Setup user home directory
# --no-log-init helps with excessively long UIDs
RUN groupadd --gid $GID $USER \
&& useradd --no-log-init --uid $GID --gid $UID -m $USER --groups sudo \
&& echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER \
&& touch /home/${USER}/.bashrc \
&& chown -R ${GID}:${UID} /home/${USER}
USER $USER
ENV SHELL /bin/bash
ENTRYPOINT []
# Setup mixin
WORKDIR /home/${USER}/ws