statping/Dockerfile

54 lines
1.6 KiB
Docker
Raw Normal View History

2020-03-06 22:18:06 +00:00
FROM node:10.17.0 AS frontend
RUN npm install yarn -g
WORKDIR /statping
COPY ./frontend/package.json .
COPY ./frontend/yarn.lock .
RUN yarn install
COPY ./frontend .
RUN yarn build && rm -rf node_modules
2020-03-07 02:30:39 +00:00
2020-03-06 22:18:06 +00:00
# Statping Golang BACKEND building from source
# Creates "/go/bin/statping" and "/usr/local/bin/sass" for copying
FROM golang:1.14-alpine AS backend
2019-04-20 03:50:19 +00:00
LABEL maintainer="Hunter Long (https://github.com/hunterlong)"
2018-11-06 03:26:37 +00:00
ARG VERSION
2020-03-06 22:18:06 +00:00
RUN apk add --update --no-cache libstdc++ gcc g++ make git ca-certificates linux-headers wget curl jq
RUN curl -L -s https://assets.statping.com/sass -o /usr/local/bin/sass && \
chmod +x /usr/local/bin/sass
WORKDIR /go/src/github.com/hunterlong/statping
ADD go.mod go.sum ./
RUN go mod download
ENV GO111MODULE on
RUN go get github.com/stretchr/testify/assert && \
go get github.com/stretchr/testify/require && \
go get github.com/GeertJohan/go.rice/rice && \
go get github.com/cortesi/modd/cmd/modd && \
go get github.com/crazy-max/xgo
COPY . .
2020-03-07 02:30:39 +00:00
COPY --from=frontend /statping/dist/ ./source/dist/
2020-03-06 22:18:06 +00:00
RUN make clean generate embed build
RUN chmod a+x statping && mv statping /go/bin/statping
2020-03-07 02:30:39 +00:00
2020-03-06 22:18:06 +00:00
# Statping main Docker image that contains all required libraries
FROM alpine:latest
RUN apk --no-cache add libgcc libstdc++ curl jq
2020-02-27 10:04:27 +00:00
2020-03-06 22:18:06 +00:00
COPY --from=backend /go/bin/statping /usr/local/bin/
COPY --from=backend /usr/local/bin/sass /usr/local/bin/
COPY --from=backend /usr/local/share/ca-certificates /usr/local/share/
2018-11-06 03:26:37 +00:00
2018-08-16 06:22:20 +00:00
WORKDIR /app
2020-02-27 10:04:27 +00:00
ENV IS_DOCKER=true
ENV STATPING_DIR=/app
ENV PORT=8080
2018-12-20 03:52:53 +00:00
EXPOSE $PORT
2018-11-06 01:34:02 +00:00
HEALTHCHECK --interval=60s --timeout=10s --retries=3 CMD curl -s "http://localhost:$PORT/health" | jq -r -e ".online==true"
2018-11-06 01:34:02 +00:00
2018-12-20 04:29:38 +00:00
CMD statping -port $PORT
2020-03-06 22:18:06 +00:00