Skip to content

Commit

Permalink
add metadata to docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbauer committed Mar 10, 2024
1 parent af44851 commit 90908ab
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: foodcoopsat/foodsoft
- name: Build and push
uses: docker/build-push-action@v4
with:
Expand All @@ -29,3 +34,6 @@ jobs:
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ COPY docker-entrypoint.sh ./
RUN apt-get install -y gosu
# Run app as unprivileged user
# USER nobody

ARG REVISION
ARG BUILDTIME
LABEL org.opencontainers.image.created=$BUILDTIME
LABEL org.opencontainers.image.authors=martin@villagefarmer.net
LABEL org.opencontainers.image.url=https://github.com/foodcoops.at/foodsoft
LABEL org.opencontainers.image.source=https://github.com/foodcoops.at/foodsoft
LABEL org.opencontainers.image.revision=$REVISION
LABEL org.opencontainers.image.vendor=IG-FoodCoops
LABEL org.opencontainers.image.licenses=AGPLv3
EXPOSE 3000

VOLUME /usr/src/app/storage
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

IMAGE_NAME=foodsoft
IMAGE_TAG:=latest
BUILD_ARGS:= --build-arg REVISION="$(shell git rev-parse --short HEAD)" --build-arg BUILDTIME="$(shell date --rfc-3339=seconds)"

image-dev:
docker buildx build --tag ${IMAGE_NAME}-rubocop:${IMAGE_TAG} --progress=plain --target=dev .

image-prod:
docker buildx build --tag ${IMAGE_NAME}:${IMAGE_TAG} --no-cache --progress=plain --target=app .
docker buildx build --tag ${IMAGE_NAME}:${IMAGE_TAG} --no-cache --progress=plain --target=app ${BUILD_ARGS} .

image-prod-dev:
docker buildx build --tag ${IMAGE_NAME}:${IMAGE_TAG} --progress=plain --target=app .
docker buildx build --tag ${IMAGE_NAME}:${IMAGE_TAG} --progress=plain --target=app ${BUILD_ARGS} .

rubocop:
docker run --rm -it -v ${PWD}:/work:ro --workdir /work foodsoft-rubocop bash
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- ${PWD}/config/initializers:/usr/src/app/config/initializers
- ${PWD}/config/environments/development.rb.SAMPLE:/usr/src/app/config/environments/production.rb
- ${PWD}/app:/usr/src/app/app
- ${PWD}/plugins:/usr/src/app/plugins
- ${PWD}/docker-entrypoint.sh:/usr/src/app/docker-entrypoint.sh
environment:
# - DATABASE_URL=mysql2://root:secret@mariadb/development?encoding=utf8mb4
Expand Down

0 comments on commit 90908ab

Please sign in to comment.