forked from elasticdotventures/__b00t__
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.ref
More file actions
131 lines (102 loc) · 3.62 KB
/
Dockerfile.ref
File metadata and controls
131 lines (102 loc) · 3.62 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# syntax=docker/dockerfile:latest
# TO BUILD:
# ./build.sh
# TO RUN:
# Docker uses the default 172.17.0.0/16 subnet for container networking.
# FROM python:3.7-alpine
# shows secret from default secret location:
# RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
# USER root
# SHELL /bin/bash
# 🤓 Dockerfile Best Practices
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
# 🤓 Buildkit syntax
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md
# docker CLI syntax
# -f :: changes context
# 🤔 Dockerfile can be sent via stdin
# tools like terraform, etc. can generate these
# there is also developer libraries
# passing ARGS
# An ARG declared before a FROM is outside of a build stage,
# AND therefore can’t be used in any instruction after a FROM
# ARG outside_build_stage
####
# Step1: init
FROM jrei/systemd-ubuntu as b00t_1n1t
ARG arrgh
ENV "STAGE"="1n1t"
RUN echo "🥾🐳 1n1t"
RUN echo "STAGE: ${STAGE} arrgh: ${arrgh}"
# Howto setup squid proxy as a sidecar container and have APT use it.
## https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-the-proxy-for-apt-for-ubuntu-18-04/
RUN \
if [ -n "$http_proxy" ]; then \
echo "Acquire { \
HTTP::proxy \"$http_proxy\"; \
HTTPS::proxy \"$https_proxy\"; \
}" > /etc/apt/apt.conf.d/http_proxy_b00t_squid; \
fi
RUN echo "apt update -y && apt upgrade -y && apt-get install -y apt-utils"
## NOTE: if squid caching proxy had issue, these lies can cache bad values.
RUN apt-get clean && apt-get update -y && apt-get upgrade -y
# Timezone
ENV DEBIAN_FRONTEND "noninteractive"
ENV TZ "Australia/Melbourne"
RUN apt-get -y install apt-utils tzdata locales
# Emoji Support
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
####
# Step2: base (everything)
FROM b00t_1n1t as b00t_b4s3
RUN echo "🥾🐳 B4S3"
MAINTAINER ops@elastic.ventures
FROM b00t_b4s3 as b00t_m4k3
## DOCKER BUILD ENHANCEMENTS
## https://docs.docker.com/develop/develop-images/build_enhancements/
##
# download github public key
#RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
# clone private repo
#RUN --mount=type=ssh git clone git@github.com:myorg/myproject.git myproject
# must run
# $ docker build --ssh default .
# docker --compress
## Dev/test git, gcc, g++
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
apt update && apt-get --no-install-recommends install -y apt-utils git gcc g++
#RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
# apt update && apt-get --no-install-recommends install -y gcc
# RUN apt-get update && apt-get install -y git gcc g++
RUN git --version
RUN apt-get install -y apt-utils dialog curl wget ca-certificates gnupg
# https://stackoverflow.com/questions/27701930/how-to-add-users-to-docker-container
RUN gosu groupadd docker
RUN useradd --create-home --gid docker brianh
# TODO: setup ps1, etc.
#VOLUME "/c0de/_b00t_"
#COPY ./docker.🐳 /c0de/_b00t_/docker.🐳/
WORKDIR /c0de/_b00t_/
ADD ./*.sh "./"
ADD ./*.bashrc "./"
# ADD /c0de/
RUN chmod +x ./source.sh
## this was screwing up permissions:
#RUN useradd -ms /bin/bash brianh
#USER brianh
#WORKDIR /home/brianh
## Stage2
FROM b00t_base as b00t_init
# CURRENT ISSUE:
# file always rebuilds, full build takes too long,
# not using stages YET
#RUN /c0de/_b00t_/source.sh "./bash.🔨/init.*.🥾.*.sh";
RUN --mount=type=bind,target="/c0de/b00t",ro
ADD "./_b00t_.bashrc" "./"
ADD "./source.sh" "./"
#RUN chmod +x "_b00t_.bashrc"
CMD [ "/bin/bash", "-c", "/c0de/_b00t_/_b00t_.bashrc"]