Dockerfile: quick re-order of operations to allow for faster re-builds on code change

This commit is contained in:
Quentin Machu 2022-04-10 18:16:25 +08:00
parent 90bb2851bf
commit d36941266e

View file

@ -13,8 +13,11 @@ RUN apk add --update --no-cache ${BUILD_DEPENDENCIES}
WORKDIR /build WORKDIR /build
# Add sources # Add dependencies
COPY . /build COPY go.mod /build
COPY go.sum /build
COPY package.json /build
COPY yarn.lock /build
# Prepare assets # Prepare assets
RUN yarn install --pure-lockfile --production && \ RUN yarn install --pure-lockfile --production && \
@ -39,13 +42,16 @@ RUN mkdir -p assets/plugins && \
/build/node_modules/jquery-tags-input/ \ /build/node_modules/jquery-tags-input/ \
assets/plugins/ assets/plugins/
# Move custom assets
RUN cp -r /build/custom/ assets/
# Get go modules and build tool # Get go modules and build tool
RUN go mod download && \ RUN go mod download && \
go get github.com/GeertJohan/go.rice/rice go get github.com/GeertJohan/go.rice/rice
# Add sources
COPY . /build
# Move custom assets
RUN cp -r /build/custom/ assets/
# Build # Build
RUN rice embed-go && \ RUN rice embed-go && \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o wg-ui . CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o wg-ui .