1
0
mirror of https://github.com/owenthereal/jqplay.git synced 2025-04-19 06:02:17 +03:00
jqplay/Dockerfile
2024-01-11 22:15:00 -08:00

89 lines
2.1 KiB
Docker

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"]