6 changed files with 111 additions and 44 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
# syntax=docker/dockerfile:experimental |
||||
|
||||
FROM ubuntu |
||||
|
||||
RUN apt update && \ |
||||
apt install -y --no-install-recommends \ |
||||
ca-certificates \ |
||||
graphviz \ |
||||
python3 \ |
||||
plantuml \ |
||||
python3-pip && \ |
||||
python3 -m pip install matplotlib && \ |
||||
rm -rf /var/lib/apt/lists/* |
||||
|
||||
# Headless chrome from https://hub.docker.com/r/justinribeiro/chrome-headless/dockerfile/ |
||||
RUN apt update && \ |
||||
apt install -y \ |
||||
apt-transport-https \ |
||||
ca-certificates \ |
||||
curl \ |
||||
gnupg \ |
||||
--no-install-recommends \ |
||||
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ |
||||
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ |
||||
&& apt-get update && apt-get install -y \ |
||||
google-chrome-stable \ |
||||
fontconfig \ |
||||
fonts-ipafont-gothic \ |
||||
fonts-wqy-zenhei \ |
||||
fonts-thai-tlwg \ |
||||
fonts-kacst \ |
||||
fonts-symbola \ |
||||
fonts-noto \ |
||||
fonts-freefont-ttf \ |
||||
--no-install-recommends \ |
||||
&& rm -rf /var/lib/apt/lists/* |
||||
|
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
# syntax=docker/dockerfile:experimental |
||||
|
||||
FROM golang:1.17.3 |
||||
|
||||
WORKDIR /data/blotter |
||||
|
||||
# deps cache |
||||
COPY ./go.mod ./go.sum /data/blotter/ |
||||
RUN go mod download -x |
||||
RUN go build all |
||||
|
||||
# build code |
||||
# build with cache: https://github.com/golang/go/issues/27719 |
||||
COPY ./ /data/blotter |
||||
RUN --mount=type=cache,target=/go/pkg/mod \ |
||||
--mount=type=cache,target=/root/.cache/go-build \ |
||||
go generate |
@ -1,11 +1,54 @@
@@ -1,11 +1,54 @@
|
||||
#!/bin/bash |
||||
|
||||
TAG=$(git describe --abbrev=0 --tags 2>/dev/null || git rev-parse --short HEAD) |
||||
DEPS_VERSION="0" |
||||
BASE_VERSION="0" |
||||
PROD_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null || git rev-parse --short HEAD) |
||||
|
||||
if [[ $1 == 'test' ]]; then |
||||
TAG="test" |
||||
BUILD_DEPS="" |
||||
BUILD_BASE="" |
||||
BUILD_PROD="1" |
||||
|
||||
for arg in "$@"; do |
||||
case "$arg" in |
||||
"test") PROD_VERSION="test" ;; |
||||
"deps") BUILD_DEPS="1" BUILD_BASE="" BUILD_PROD="" ;; |
||||
"base") BUILD_DEPS="" BUILD_BASE="1" BUILD_PROD="" ;; |
||||
esac |
||||
done |
||||
|
||||
DEPS_IMAGE="ohyee/blotter:deps_${DEPS_VERSION}" |
||||
BASE_IMAGE="ohyee/blotter:base_${BASE_VERSION}" |
||||
PROD_IMAGE="ohyee/blotter:${PROD_VERSION}" |
||||
|
||||
echo -e "DEPS VERSION: $DEPS_IMAGE \t\t `if [[ -n \"$BUILD_DEPS\" ]]; then echo '√'; fi`" |
||||
echo -e "BASE VERSION: $BASE_IMAGE \t\t `if [[ -n \"$BUILD_BASE\" ]]; then echo '√'; fi`" |
||||
echo -e "PROD VERSION: $PROD_IMAGE \t\t `if [[ -n \"$BUILD_PROD\" ]]; then echo '√'; fi`" |
||||
echo "" |
||||
|
||||
function build_docker() { |
||||
echo "Building docker image $IMAGE from $DOCKER_FILE" |
||||
docker build \ |
||||
--build-arg DEPS_IMAGE=$DEPS_IMAGE \ |
||||
--build-arg BASE_IMAGE=$BASE_IMAGE \ |
||||
--build-arg PROD_IMAGE=$PROD_IMAGE \ |
||||
-t $IMAGE \ |
||||
`if [[ -n $DOCKER_FILE ]]; then echo -n "-f $DOCKER_FILE"; fi` \ |
||||
. |
||||
} |
||||
|
||||
if [[ -n $BUILD_PROD ]]; then |
||||
IMAGE=$PROD_IMAGE |
||||
build_docker |
||||
fi |
||||
|
||||
if [[ -n $BUILD_BASE ]]; then |
||||
IMAGE=$BASE_IMAGE |
||||
DOCKER_FILE="Dockerfile.base" |
||||
build_docker |
||||
fi |
||||
|
||||
IMAGE="ohyee/blotter:${TAG}" |
||||
echo $IMAGE |
||||
docker build -t ${IMAGE} . |
||||
if [[ -n $BUILD_DEPS ]]; then |
||||
IMAGE=$DEPS_IMAGE |
||||
DOCKER_FILE="Dockerfile.deps" |
||||
build_docker |
||||
fi |
Loading…
Reference in new issue