Skip to content

Commit

Permalink
Merge branch 'basegitlab' into theme
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Aug 5, 2024
2 parents 7b94dbf + ad67b39 commit 82563d1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
31 changes: 23 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
image: docker:20.10.16

stages:
- build
- build-amd64
- build-arm64
- tag-images

variables:
Expand All @@ -13,6 +14,12 @@ variables:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""

cache:
key: npm-cache
paths:
- .buildx-cache

services:
- docker:20.10.16-dind

Expand All @@ -23,13 +30,13 @@ before_script:
- export TAG_MINOR=$(echo $BASE_TAG | cut -d'.' -f1,2)
- export TAG_PATCH=$(echo $BASE_TAG | cut -d'.' -f1,2,3)
- export BUILD_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
- docker login $REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- echo $CI_REGISTRY_PASSWORD | docker login $REGISTRY -u $CI_REGISTRY_USER --password-stdin
- docker run --privileged --rm tonistiigi/binfmt --install all
- docker buildx create --name mybuilder --use
- docker buildx inspect --bootstrap

build-backend-amd64:
stage: build
stage: build-amd64
only:
- /^.*-(pro|theme)+$/
script:
Expand All @@ -45,10 +52,12 @@ build-backend-amd64:
EOT
- |
docker buildx build --platform linux/amd64 --push \
-t $REGISTRY/$IMAGE_FRONTEND:amd64-$CI_COMMIT_SHORT_SHA backend
--cache-from=type=local,src=.buildx-cache \
--cache-to=type=local,dest=.buildx-cache \
-t $REGISTRY/$IMAGE_BACKEND:amd64-$CI_COMMIT_SHORT_SHA backend
build-backend-arm64:
stage: build
stage: build-arm64
only:
- /^.*-(pro|theme)+$/
script:
Expand All @@ -64,10 +73,12 @@ build-backend-arm64:
EOT
- |
docker buildx build --platform linux/arm64 --push \
-t $REGISTRY/$IMAGE_FRONTEND:arm64-$CI_COMMIT_SHORT_SHA backend
--cache-from=type=local,src=.buildx-cache \
--cache-to=type=local,dest=.buildx-cache \
-t $REGISTRY/$IMAGE_BACKEND:arm64-$CI_COMMIT_SHORT_SHA backend
build-frontend-amd64:
stage: build
stage: build=-amd64
only:
- /^.*-(pro|theme)+$/
script:
Expand All @@ -83,12 +94,14 @@ build-frontend-amd64:
EOT
- |
docker buildx build --platform linux/amd64 --push \
--cache-from=type=local,src=.buildx-cache \
--cache-to=type=local,dest=.buildx-cache \
-t $REGISTRY/$IMAGE_FRONTEND:amd64-$CI_COMMIT_SHORT_SHA frontend
build-frontend-arm64:
only:
- /^.*-(pro|theme)+$/
stage: build
stage: build-arm64
script:
- |
cat <<EOT > frontend/public/gitinfo.json
Expand All @@ -102,6 +115,8 @@ build-frontend-arm64:
EOT
- |
docker buildx build --platform linux/arm64 --push \
--cache-from=type=local,src=.buildx-cache \
--cache-to=type=local,dest=.buildx-cache \
-t $REGISTRY/$IMAGE_FRONTEND:arm64-$CI_COMMIT_SHORT_SHA frontend
Expand Down
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM node:20 AS build
WORKDIR /usr/src/app
COPY . .

RUN npm install \
&& npm run build
RUN --mount=type=cache,target=/root/.npm \
npm install && npm run build

# Stage 2: Create the final image without source files
FROM ghcr.io/ticketz-oss/node
Expand Down
5 changes: 2 additions & 3 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ COPY . .

ENV NODE_OPTIONS --openssl-legacy-provider

RUN npm install \
&& echo -e "\n\nBulding...\n" \
&& npm run build
RUN --mount=type=cache,target=/root/.npm \
npm install && npm run build

FROM ghcr.io/ticketz-oss/nginx-alpine

Expand Down

0 comments on commit 82563d1

Please sign in to comment.