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