support executing custom commands when building image

This commit is contained in:
MaysWind
2021-01-24 10:56:02 +08:00
parent 0e642821eb
commit 20bcfe4d83
3 changed files with 16 additions and 2 deletions

View File

@@ -1,8 +1,9 @@
# Build backend binary file
FROM golang:1.14.10-alpine3.12 AS be-builder
RUN apk add git gcc g++ libc-dev
WORKDIR /go/src/github.com/mayswind/lab
COPY . .
RUN docker/backend-build-pre-setup.sh
RUN apk add git gcc g++ libc-dev
RUN VERSION=`grep '"version": ' package.json | awk -F ':' '{print $2}' | tr -d ' ' | tr -d ',' | tr -d '"'` \
&& COMMIT_HASH=$(git rev-parse --short HEAD) \
&& GOOS=linux \
@@ -13,9 +14,10 @@ RUN chmod +x lab
# Build frontend files
FROM node:12.19.0-alpine3.12 AS fe-builder
RUN apk add git
WORKDIR /go/src/github.com/mayswind/lab
COPY . .
RUN docker/frontend-build-pre-setup.sh
RUN apk add git
RUN npm install && npm run build
# Package docker image

View File

@@ -0,0 +1,6 @@
#!/bin/sh
CUR_DIR=$(dirname "$0");
if [ -x "${CUR_DIR}/custom-backend-pre-setup.sh" ]; then
"${CUR_DIR}"/custom-backend-pre-setup.sh
fi

View File

@@ -0,0 +1,6 @@
#!/bin/sh
CUR_DIR=$(dirname "$0");
if [ -x "${CUR_DIR}/custom-frontend-pre-setup.sh" ]; then
"${CUR_DIR}"/custom-frontend-pre-setup.sh
fi