From ef9e28c95bbe460c81473219a619749d413dd23c Mon Sep 17 00:00:00 2001 From: tanshu Date: Thu, 28 Oct 2021 09:55:09 +0530 Subject: [PATCH] Docker: Updated the dockerfile and deploy script to better use docker cacheing --- deploy.sh | 10 ++++++++++ docker/app/Dockerfile | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index f7768f2..8e03e9c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -12,6 +12,16 @@ else ./version_bump.sh fi +# Download the package.json for caching +curl --silent 'https://git.tanshu.com/tanshu/barker/raw/tag/latest/bookie/package.json' \ + | sed 's/\"version\": \"[0-9\.]*\"/"version": "0.0.0"/g' \ + > "$parent_path/docker/app/package.json" + +# Download the package.json for caching +curl --silent 'https://git.tanshu.com/tanshu/barker/raw/tag/latest/barker/pyproject.toml' \ + | sed 's/version = \"[0-9\.]*\"/version = "0.0.0"/g' \ + > "$parent_path/docker/app/pyproject.toml" + cd "$parent_path/docker/app" || exit docker build --tag barker:latest . cd "$parent_path/docker" || exit diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index c6ccdbc..97e8ba1 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -1,14 +1,22 @@ FROM node:latest AS builder +RUN mkdir -p /app/bookie +COPY package.json /app/bookie/package.json +RUN cd /app/bookie \ + && npm install --unsafe-perm \ + && mv /app/bookie/node_modules / \ + && cd / \ + && rm -rf /app ADD https://git.tanshu.com/api/v1/repos/tanshu/barker/tags /tags.json RUN git clone --single-branch --depth 1 --branch latest https://git.tanshu.com/tanshu/barker.git /app WORKDIR /app/bookie -RUN npm install --unsafe-perm && /app/bookie/node_modules/.bin/ng build +RUN mv /node_modules /app/bookie/ \ + && /app/bookie/node_modules/.bin/ng build FROM python:latest LABEL maintainer="Amritanshu " -ADD https://git.tanshu.com/tanshu/barker/raw/tag/latest/barker/pyproject.toml /app/pyproject.toml +COPY pyproject.toml /app/pyproject.toml RUN apt-get update && \ apt-get install -y locales && \