forked from owenthereal/jqplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
88 lines (68 loc) · 2.11 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
FROM ubuntu as jqbuilder
ARG JQ_TAG=jq-1.7.1
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8
RUN apt-get update && \
apt-get install -y \
build-essential \
autoconf \
libtool \
git \
; \
apt-get clean
RUN git clone --recurse-submodules https://github.com/jqlang/jq.git && \
cd jq && \
git checkout $JQ_TAG && \
autoreconf -i && \
./configure \
--disable-dependency-tracking \
--disable-valgrind \
--with-oniguruma=builtin \
--enable-static \
--enable-all-static \
--prefix=/usr/local && \
make install
FROM golang:latest as gotest
COPY --from=jqbuilder /usr/local/bin/jq /usr/local/bin/jq
WORKDIR $GOPATH/src/github.com/owenthereal/jqplay
ARG TIMESTAMP
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
go test ./... -count=1 -race -v
FROM golang:latest as gobuilder
ARG TARGETOS TARGETARCH
RUN apt update && apt install -y --no-install-recommends curl gpg
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt install -y --no-install-recommends \
nodejs \
npm \
&& npm install --global yarn
WORKDIR $GOPATH/src/github.com/owenthereal/jqplay
ENV CGO_ENABLED=0 GOBIN=$GOPATH/bin GOOS=$TARGETOS GOARCH=$TARGETARCH GOFLAGS="-buildvcs=false"
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
make build
FROM ubuntu
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8
RUN apt-get update && \
apt-get install -y \
ca-certificates \
&& \
apt-get clean
RUN useradd -m jqplay
USER jqplay
WORKDIR /app
ENV PATH="/app:${PATH}"
COPY --from=jqbuilder /usr/local/bin/jq /app
COPY --from=gobuilder /go/bin/* /app
ENV PORT 8080
EXPOSE 8080
ENTRYPOINT ["jqplay"]