-separate commands in two, docker build & save to allow multi-line commands

-have arg and env variables
This commit is contained in:
Ulf Gebhardt 2021-04-17 13:15:45 +02:00
parent 6d890e28ae
commit 79beb840c5
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
4 changed files with 72 additions and 26 deletions

View File

@ -55,9 +55,19 @@ jobs:
# NEO4J ##################################################################
##########################################################################
- name: Neo4J | Build `community` image
run: |
docker build --target community -t "ocelotsocialnetwork/neo4j:latest" -t "ocelotsocialnetwork/neo4j:community" -t "ocelotsocialnetwork/neo4j:${VERSION}" -t "ocelotsocialnetwork/neo4j:${BUILD_VERSION}" --build-arg BUILD_DATE=$BUILD_DATE --build-arg BUILD_VERSION=$BUILD_VERSION --build-arg BUILD_COMMIT=$BUILD_COMMIT neo4j/
docker save "ocelotsocialnetwork/neo4j" > /tmp/neo4j.tar
run: >
docker build
--target community
-t "ocelotsocialnetwork/neo4j:latest"
-t "ocelotsocialnetwork/neo4j:community"
-t "ocelotsocialnetwork/neo4j:${VERSION}"
-t "ocelotsocialnetwork/neo4j:${BUILD_VERSION}"
--build-arg BBUILD_DATE=$BUILD_DATE
--build-arg BBUILD_VERSION=$BUILD_VERSION
--build-arg BBUILD_COMMIT=$BUILD_COMMIT
neo4j/
- name: Neo4J | Save docker image
run: docker save "ocelotsocialnetwork/neo4j" > /tmp/neo4j.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
@ -91,10 +101,19 @@ jobs:
##########################################################################
# BUILD BACKEND DOCKER IMAGE (production) ################################
##########################################################################
- name: backend | Build `production` image
run: |
docker build --target production -t "ocelotsocialnetwork/backend:latest" -t "ocelotsocialnetwork/backend:${VERSION}" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" --build-arg BUILD_DATE=$BUILD_DATE --build-arg BUILD_VERSION=$BUILD_VERSION --build-arg BUILD_COMMIT=$BUILD_COMMIT backend/
docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar
- name: Backend | Build `production` image
run: >
docker build
--target production
-t "ocelotsocialnetwork/backend:latest"
-t "ocelotsocialnetwork/backend:${VERSION}"
-t "ocelotsocialnetwork/backend:${BUILD_VERSION}"
--build-arg BBUILD_DATE=$BUILD_DATE
--build-arg BBUILD_VERSION=$BUILD_VERSION
--build-arg BBUILD_COMMIT=$BUILD_COMMIT
backend/
- name: Backend | Save docker image
run: docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
@ -128,10 +147,19 @@ jobs:
##########################################################################
# BUILD WEBAPP DOCKER IMAGE (build) ######################################
##########################################################################
- name: webapp | Build `production` image
run: |
docker build --target production -t "ocelotsocialnetwork/webapp:latest" -t "ocelotsocialnetwork/webapp:${VERSION}" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" --build-arg BUILD_DATE=$BUILD_DATE --build-arg BUILD_VERSION=$BUILD_VERSION --build-arg BUILD_COMMIT=$BUILD_COMMIT webapp/
docker save "ocelotsocialnetwork/webapp" > /tmp/webapp.tar
- name: Webapp | Build `production` image
run: >
docker build
--target production
-t "ocelotsocialnetwork/webapp:latest"
-t "ocelotsocialnetwork/webapp:${VERSION}"
-t "ocelotsocialnetwork/webapp:${BUILD_VERSION}"
--build-arg BBUILD_DATE=$BUILD_DATE
--build-arg BBUILD_VERSION=$BUILD_VERSION
--build-arg BBUILD_COMMIT=$BUILD_COMMIT
webapp/
- name: Webapp | Save docker image
run: docker save "ocelotsocialnetwork/webapp" > /tmp/webapp.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
@ -165,11 +193,19 @@ jobs:
##########################################################################
# BUILD MAINTENANCE DOCKER IMAGE (build) #################################
##########################################################################
- name: maintenance | Build `production` image
- name: Maintenance | Build `production` image
# TODO: --target production
run: |
docker build -t "ocelotsocialnetwork/maintenance:latest" -t "ocelotsocialnetwork/maintenance:${VERSION}" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" --build-arg BUILD_DATE=$BUILD_DATE --build-arg BUILD_VERSION=$BUILD_VERSION --build-arg BUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
docker save "ocelotsocialnetwork/maintenance" > /tmp/maintenance.tar
run: >
docker build
-t "ocelotsocialnetwork/maintenance:latest"
-t "ocelotsocialnetwork/maintenance:${VERSION}"
-t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}"
--build-arg BBUILD_DATE=$BUILD_DATE
--build-arg BBUILD_VERSION=$BUILD_VERSION
--build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
-f webapp/Dockerfile.maintenance
- name: Maintenance | Save docker image
run: docker save "ocelotsocialnetwork/maintenance" > /tmp/maintenance.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:

View File

@ -3,14 +3,18 @@
##################################################################################
FROM node:12.19.0-alpine3.10 as base
# ENVs
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
ENV DOCKER_WORKDIR="/app"
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ARG BUILD_DATE="1970-01-01T00:00:00.00Z"
ARG BBUILD_DATE="1970-01-01T00:00:00.00Z"
ENV BUILD_DATE=$BBUILD_DATE
## We cannot do $(yarn run version)-${BUILD_NUMBER} here so we default to 0.0.0-0
ARG BUILD_VERSION="0.0.0-0"
ARG BBUILD_VERSION="0.0.0-0"
ENV BUILD_VERSION=$BBUILD_VERSION
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ARG BUILD_COMMIT="0000000"
ARG BBUILD_COMMIT="0000000"
ENV BUILD_COMMIT=$BBUILD_COMMIT
## SET NODE_ENV
ENV NODE_ENV="production"
## App relevant Envs

View File

@ -3,13 +3,16 @@
##################################################################################
FROM neo4j:3.5.14 as community
# ENVs (available in production aswell, can be overwritten by commandline or env file)
# ENVs
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ARG BUILD_DATE="1970-01-01T00:00:00.00Z"
ARG BBUILD_DATE="1970-01-01T00:00:00.00Z"
ENV BUILD_DATE=$BBUILD_DATE
## We cannot do $(yarn run version)-${BUILD_NUMBER} here so we default to 0.0.0-0
ARG BUILD_VERSION="0.0.0-0"
ARG BBUILD_VERSION="0.0.0-0"
ENV BUILD_VERSION=$BBUILD_VERSION
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ARG BUILD_COMMIT="0000000"
ARG BBUILD_COMMIT="0000000"
ENV BUILD_COMMIT=$BBUILD_COMMIT
# Labels
LABEL org.label-schema.build-date="${BUILD_DATE}"

View File

@ -3,15 +3,18 @@
##################################################################################
FROM node:12.19.0-alpine3.10 as base
# ENVs (available in production aswell, can be overwritten by commandline or env file)
# ENVs
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
ENV DOCKER_WORKDIR="/app"
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ARG BUILD_DATE="1970-01-01T00:00:00.00Z"
ARG BBUILD_DATE="1970-01-01T00:00:00.00Z"
ENV BUILD_DATE=$BBUILD_DATE
## We cannot do $(yarn run version)-${BUILD_NUMBER} here so we default to 0.0.0-0
ARG BUILD_VERSION="0.0.0-0"
ARG BBUILD_VERSION="0.0.0-0"
ENV BUILD_VERSION=$BBUILD_VERSION
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ARG BUILD_COMMIT="0000000"
ARG BBUILD_COMMIT="0000000"
ENV BUILD_COMMIT=$BBUILD_COMMIT
## SET NODE_ENV
ENV NODE_ENV="production"
## App relevant Envs