diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d7497afa4..a202168c1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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: @@ -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'] }} diff --git a/Dockerfile b/Dockerfile index a059a1403..0ab1f820c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index 762794d2f..2fef97245 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 0546100ba..fd26afa3d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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