Skip to content

Modular logistics and supply chain operating system (LSOS)

modified to setup composer auth for private packages/extensions in builds and deploy if arg provided

Ronald A. Richardson406ca111996a
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index 2fd45fc8..36ca060c 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -10,6 +10,8 @@ concurrency:
env:
PROJECT: ${{ secrets.PROJECT }}
+ COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_GITHUB_AUTH_TOKEN }}"}}'
+
jobs:
build_service:
name: Build and Deploy the Service
@@ -49,6 +51,7 @@ jobs:
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}-${{ env.STACK }}
VERSION: ${{ env.VERSION }}
+ COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_GITHUB_AUTH_TOKEN }}"}}'
with:
push: true
files: |
diff --git a/docker-bake.hcl b/docker-bake.hcl
index 854fa39e..a9620f73 100644
--- a/docker-bake.hcl
+++ b/docker-bake.hcl
@@ -1,4 +1,5 @@
// docker-bake.hcl
+variable "COMPOSER_AUTH" { default = "" }
variable "REGISTRY" { default = "" }
variable "VERSION" { default = "latest" }
@@ -25,6 +26,10 @@ target "app" {
"${REGISTRY}:${tgt}-%s",
compact(["latest", VERSION])
) : []
+
+ args = {
+ "COMPOSER_AUTH" = COMPOSER_AUTH
+ }
}
target "app-httpd" {
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 78f2c781..4e921b75 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -53,9 +53,14 @@ WORKDIR /
# Create unique instance ID
RUN echo $(cat /proc/sys/kernel/random/uuid) > /.fleetbase
-# Setup composer auth if applicable
-RUN mkdir -p ~/.composer
-COPY composer-auth.jso[n] ~/.composer/auth.json
+# Setup composer root directory
+RUN mkdir -p /root/.composer
+
+# Docker image will accept a build-arg named COMPOSER_AUTH
+ARG COMPOSER_AUTH
+
+# If applicable use `COMPOSER_AUTH` build-arg to generate the auth.json file.
+RUN if [ -n "$COMPOSER_AUTH" ]; then echo $COMPOSER_AUTH > /root/.composer/auth.json; fi
# Set environment
ARG ENVIRONMENT=production