-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
215 lines (168 loc) · 8.73 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
FROM ubuntu:22.04
ENV CLANG_VERSION=15
RUN apt-get update --fix-missing && apt-get upgrade -y
RUN apt-get clean
RUN apt-get install -y curl wget git xz-utils nano make
RUN apt-get install -y sudo ca-certificates file dpkg
RUN apt-get install -y zip unzip zsh clang-${CLANG_VERSION}
RUN useradd -m -d /home/parigot -s /bin/bash -G sudo parigot
RUN usermod -aG sudo parigot
# we allow sudo
RUN mkdir /home/parigot/deps
RUN mkdir /home/parigot/tmp
WORKDIR /home/parigot/deps
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
## golang version
ENV GOLANG_VERSION_HOST="1.21.1"
ENV GOLANG_VERSION_HOST_SHORT="1.21"
## wasmtime version
ENV WASMTIME_VERSION=12.0.2
# hugo version for website
ENV HUGO_VERSION=0.114.1
# protoc because some plugins don't work with buf
ENV PROTOC_VERSION=23.3
# caddy
ENV CADDY_VERSION=2.7.4
ENV docker_url="https://download.docker.com/linux/static/stable/${docker_arch}"
ENV docker_version="24.0.6"
#figure out ARCH and download correct tarballs
RUN set -e; \
unamearch="$(uname -m)" ; \
unameos="$(uname -s)"; \
if [ "$unameos" != "Linux" ] ; \
then \
echo "build failed, operating system inside container not linux -- $unameos"; return 1;\
fi ;\
case $unamearch in \
aarch64) wget -O go.tar.gz -q https://go.dev/dl/go${GOLANG_VERSION_HOST}.linux-arm64.tar.gz ; \
wget -O wasmtime.tar.xz -q https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-aarch64-linux.tar.xz ; \
export WASMTIME_SUFFIX="v${WASMTIME_VERSION}-aarch64-linux"; \
echo "export WASMTIME_SUFFIX=${WASMTIME_SUFFIX}" > .suffix; \
wget -O hugo_${HUGO_VERSION}.deb -q https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-arm64.deb; \
wget -O protoc-${PROTOC_VERSION}.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-aarch_64.zip; \
docker_url="https://download.docker.com/linux/static/stable/aarch64"; \
curl -L -o /home/parigot/deps/caddy${CADDY_VERSION}.tar.gz https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_arm64.tar.gz; \
curl -fsSL $docker_url/docker-$docker_version.tgz | tar zxvf - --strip 1 -C /usr/bin docker/docker;; \
x86_64) wget -O go.tar.gz -q https://go.dev/dl/go${GOLANG_VERSION_HOST}.linux-amd64.tar.gz ; \
wget -O wasmtime.tar.xz -q https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-x86_64-linux.tar.xz ; \
export WASMTIME_SUFFIX="v${WASMTIME_VERSION}-x86_64-linux"; \
echo "export WASMTIME_SUFFIX=${WASMTIME_SUFFIX}" > .suffix; \
wget -O hugo_${HUGO_VERSION}.deb -q https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.deb; \
wget -O protoc-${PROTOC_VERSION}.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip; \
docker_url="https://download.docker.com/linux/static/stable/x86_64"; \
curl -L -o /home/parigot/deps/caddy${CADDY_VERSION}.tar.gz https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz; \
curl -fsSL $docker_url/docker-$docker_version.tgz | tar zxvf - --strip 1 -C /usr/bin docker/docker;; \
*) echo "unknown architecture type, or not running in a linux container: aborting..."; return 1 ;; \
esac;
WORKDIR /home/parigot/deps
ENV GOROOT=
ENV GOROOT_BOOTSTRAP=
# install Hugo
WORKDIR /home/parigot/deps
RUN dpkg -i hugo_${HUGO_VERSION}.deb
RUN rm -f hugo_${HUGO_VERSION}.deb
# install protoc
RUN mkdir /home/parigot/deps/protoc-${PROTOC_VERSION}
WORKDIR /home/parigot/deps/protoc-${PROTOC_VERSION}
RUN mv ../protoc-${PROTOC_VERSION}.zip .
RUN unzip protoc-${PROTOC_VERSION}.zip
# install golang
WORKDIR /home/parigot/deps
RUN tar xf go.tar.gz
RUN mv go go${GOLANG_VERSION_HOST}
RUN rm go.tar.gz
## install wasmtime
WORKDIR /home/parigot/deps
RUN unxz wasmtime.tar.xz
RUN tar xf wasmtime.tar
RUN rm wasmtime.tar
RUN . /home/parigot/deps/.suffix; mv wasmtime-$WASMTIME_SUFFIX wasmtime
## install caddy
WORKDIR /home/parigot/deps
RUN tar xzf caddy${CADDY_VERSION}.tar.gz caddy
RUN rm caddy${CADDY_VERSION}.tar.gz
# install protocol buffers
ENV PB_VERSION="21.12"
ENV PB_REL="https://github.com/protocolbuffers/protobuf/releases"
#RUN curl -s -LO $PB_REL/download/v${PB_VERSION}/protoc-${PB_VERSION}-linux-x86_64.zip
RUN mkdir /home/parigot/tools
WORKDIR /home/parigot/tools
ENV PB_REL=""
## tinygo does not support enough of reflect package to run "standard" go protobufs
## using the google tools ... there are other implementation of protobufs that
## do work
## https://github.com/knqyf263/go-plugin
## https://github.com/planetscale/vtprotobuf
# symlink all the single binaries in tools/bin
RUN mkdir /home/parigot/tools/bin
WORKDIR /home/parigot/tools/bin
RUN ln -s /home/parigot/deps/wasmtime/wasmtime /home/parigot/tools/bin/wasmtime
RUN ln -s /usr/bin/python3 /home/parigot/tools/bin/python
RUN ln -s /home/parigot/deps/go${GOLANG_VERSION_HOST} /home/parigot/tools
RUN ln -s /home/parigot/deps/go${GOLANG_VERSION_HOST}/bin/go /home/parigot/tools/bin/go${GOLANG_VERSION_HOST}
## if something called "go" is not in your path, the dev container will not run
RUN ln -s /home/parigot/deps/go${GOLANG_VERSION_HOST}/bin/go /home/parigot/tools/bin/go
RUN ln -s /usr/lib/llvm-${CLANG_VERSION}/bin/clang /home/parigot/tools/bin/clang
RUN ln -s /usr/lib/llvm-${CLANG_VERSION}/bin/clang /home/parigot/tools/bin/cc
RUN ln -s /usr/local/bin/hugo /home/parigot/tools/bin
RUN ln -s /home/parigot/deps/protoc-${PROTOC_VERSION}/bin/protoc /home/parigot/tools/bin
RUN ln -s /home/parigot/deps/caddy /home/parigot/tools/bin
# docker socket dir?
RUN mkdir /var/run/parigot
RUN chown parigot /var/run/parigot /home/parigot
RUN chgrp parigot /var/run/parigot /home/parigot
#RUN chmod g+w /var/run/parigot
# safety
RUN mkdir -p /home/parigot/tools/bin
RUN chown -R parigot /home/parigot/tools
RUN chgrp -R parigot /home/parigot/tools
RUN mkdir -p /home/parigot/deps
RUN chown -R parigot /home/parigot/deps
RUN chgrp -R parigot /home/parigot/deps
#zsh
RUN chsh -s /usr/bin/zsh parigot
# get ready for koyeb completions... does not work with multiarch builds
#RUN mkdir -p /etc/bash_completion.d
#RUN touch /etc/bash_completion.d/koyeb
#RUN chown parigot /etc/bash_completion.d/koyeb
#RUN chgrp parigot /etc/bash_completion.d/koyeb
#temporary PATH hack
USER parigot
ENV PATH=/workspaces/parigot/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/parigot/tools/bin
## koyeb -- this installs koyeb for parigot
RUN curl -fsSL https://raw.githubusercontent.com/koyeb/koyeb-cli/master/install.sh | sh
RUN /home/parigot/.koyeb/bin/koyeb completion bash > /etc/bash_completion.d/koyeb
ENV PROTOC_GO_VERSION=1.28.1
ENV PROTOC_GRPC_VERSION=1.51.0
RUN ls -l /home/parigot/deps/
RUN echo go${GOLANG_VERSION_HOST} install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
RUN go${GOLANG_VERSION_HOST} install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
RUN go${GOLANG_VERSION_HOST} install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOC_GO_VERSION}
RUN go${GOLANG_VERSION_HOST} install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest
RUN go${GOLANG_VERSION_HOST} install github.com/bufbuild/buf/cmd/buf@v1.26
RUN go${GOLANG_VERSION_HOST} install golang.org/x/tools/gopls@latest
RUN go${GOLANG_VERSION_HOST} install github.com/go-delve/delve/cmd/dlv@latest
RUN go${GOLANG_VERSION_HOST} install honnef.co/go/tools/cmd/staticcheck@latest
RUN go${GOLANG_VERSION_HOST} install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.20.0
RUN go${GOLANG_VERSION_HOST} install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest
RUN go${GOLANG_VERSION_HOST} install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
RUN go${GOLANG_VERSION_HOST} install github.com/tetratelabs/wazero/cmd/wazero@v1.5.0
RUN go${GOLANG_VERSION_HOST} install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
#RUN go${GOLANG_VERSION_HOST} install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GRPC_VERSION}
#RUN go${GOLANG_VERSION_HOST} install github.com/onsi/ginkgo/v2/ginkgo
RUN ln -s /home/parigot/go/bin/* /home/parigot/tools/bin
RUN ln -s /workspaces/parigot/build/protoc-gen-parigot /home/parigot/tools/bin/protoc-gen-parigot
RUN mkdir ~/.ssh
RUN chmod 700 ~/.ssh
RUN ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
ENV KOYEB_BIN=/home/parigot/.koyeb/bin
# set some vars
ENV DOCKER_HOST=unix:///var/run/docker-host.sock
ENV BUILDKIT_PROGRESS=plain
WORKDIR /workspaces/parigot
ENV WABTTOOLS=/home/parigot/tools/wabt
ENV TOOLS=/home/parigot/tools
ENV PATH=/workspaces/parigot/build:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:$TOOLS/bin:$WABTTOOLS/bin:$KOYEB_BIN
ENV CC=clang
ENV GOFLAGS="-buildvcs=false"
ENTRYPOINT ["bash"]