Skip to content

Commit ed6d76f

Browse files
author
Jeremy Price
committed
null-cache for ubunti and --no-dev for alpine.. emulated
1 parent 764f933 commit ed6d76f

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

.github/workflows/docker.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,68 @@ jobs:
8686
# Use tags / labels provided by 'docker/metadata-action' above
8787
tags: ${{ steps.meta_build.outputs.tags }}
8888
labels: ${{ steps.meta_build.outputs.labels }}
89+
alpine-build:
90+
# Ensure this job never runs on forked repos. It's only executed for 'jerm/snipe-it'
91+
if: github.repository == 'grokability/jerm-it'
92+
runs-on: ubuntu-latest
93+
env:
94+
# Define tags to use for Docker images based on Git tags/branches (for docker/metadata-action)
95+
# For a new commit on default branch (master), use the literal tag 'latest' on Docker image.
96+
# For a new commit on other branches, use the branch name as the tag for Docker image.
97+
# For a new tag, copy that tag name as the tag for Docker image.
98+
IMAGE_TAGS: |
99+
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},suffix=-alpine
100+
type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }},suffix=-alpine
101+
type=ref,event=tag,suffix=-alpine
102+
type=semver,pattern=v{{major}}-latest-alpine
103+
# Define default tag "flavor" for docker/metadata-action per
104+
# https://github.com/docker/metadata-action#flavor-input
105+
# We turn off 'latest' tag by default.
106+
TAGS_FLAVOR: |
107+
latest=false
108+
109+
steps:
110+
# https://github.com/actions/checkout
111+
- name: Checkout codebase
112+
uses: actions/checkout@v4
113+
114+
# https://github.com/docker/setup-buildx-action
115+
- name: Setup Docker Buildx
116+
uses: docker/setup-buildx-action@v3
117+
118+
# https://github.com/docker/login-action
119+
- name: Login to DockerHub
120+
# Only login if not a PR, as PRs only trigger a Docker build and not a push
121+
if: github.event_name != 'pull_request'
122+
uses: docker/login-action@v3
123+
with:
124+
username: ${{ secrets.DOCKER_USERNAME }}
125+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
126+
127+
###############################################
128+
# Build/Push the 'jermgroks/jerm-it' image
129+
###############################################
130+
# https://github.com/docker/metadata-action
131+
# Get Metadata for docker_build step below
132+
- name: Sync metadata (tags, labels) from GitHub to Docker for 'jerm-it' image
133+
id: meta_build
134+
uses: docker/metadata-action@v5
135+
with:
136+
images: jermgroks/jerm-it
137+
tags: ${{ env.IMAGE_TAGS }}
138+
flavor: ${{ env.TAGS_FLAVOR }}
139+
140+
# https://github.com/docker/build-push-action
141+
- name: Build and push 'jerm-it' image
142+
id: docker_build
143+
uses: docker/build-push-action@v6
144+
with:
145+
context: .
146+
file: ./Dockerfile.alpine
147+
platforms: linux/arm64
148+
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
149+
# but we ONLY do an image push to DockerHub if it's NOT a PR
150+
push: ${{ github.event_name != 'pull_request' }}
151+
# Use tags / labels provided by 'docker/metadata-action' above
152+
tags: ${{ steps.meta_build.outputs.tags }}
153+
labels: ${{ steps.meta_build.outputs.labels }}

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
110110

111111
# Get dependencies
112112
USER docker
113-
RUN composer install --no-dev --working-dir=/var/www/html && rm -rf /home/docker/.cache/composer && rm -rf /var/www/html/vendor/*/*/.git
113+
RUN COMPOSER_CACHE_DIR=/dev/null composer install --working-dir=/var/www/html --no-dev
114+
#composer install --no-dev --working-dir=/var/www/html && rm -rf /home/docker/.cache/composer && rm -rf /var/www/html/vendor/*/*/.git
114115
USER root
115116

116117
############### APPLICATION INSTALL/INIT #################

Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ RUN mkdir -p /var/www/.composer && chown apache /var/www/.composer
7373

7474
# Install dependencies
7575
USER apache
76-
RUN COMPOSER_CACHE_DIR=/dev/null composer install --working-dir=/var/www/html
76+
RUN COMPOSER_CACHE_DIR=/dev/null composer install --working-dir=/var/www/html --no-dev
7777

7878
USER root
7979

0 commit comments

Comments
 (0)