fun, image tagging, and SOURCE_TAG

pull/53/head
kouhai dev 2023-03-16 21:09:27 -07:00
parent 758986e170
commit dfdb6b4020
3 changed files with 45 additions and 10 deletions

View File

@ -1,19 +1,50 @@
variables:
image: &docker-git docker:rc-git
volumes:
- &docker.sock /var/run/docker.sock:/var/run/docker.sock
environment:
common: &common-env
NAME: gitea.treehouse.systems/treehouse/mastodon
pipeline:
build:
image: docker:rc-git
image: *docker-git
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- *docker.sock
environment:
<<: *common-env
commands:
- docker version
- docker image build -f Dockerfile . -t gitea.treehouse.systems/treehouse/mastodon:latest
- docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $NAME:latest
- docker tag $NAME:latest $NAME:$CI_COMMIT_SHA
tag-nightly:
image: *docker-git
volumes:
- *docker.sock
environment:
<<: *common-env
commands:
- docker tag $NAME:latest $NAME:$(date -Idate -u)
# maybe we can use tags someday,,,
# tag-tag:
# image: *docker-git
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# commands:
# - docker tag $NAME:latest $NAME:$CI_COMMIT_TAG
# when:
# event: tag
push:
image: docker:rc-git
image: *docker-git
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- *docker.sock
environment:
<<: *common-env
commands:
- echo $REGISTRY_SECRET | docker login -u ariadne --password-stdin gitea.treehouse.systems
- docker image push --all-tags gitea.treehouse.systems/treehouse/mastodon
- docker image push --all-tags $NAME
when:
event: [push, tag]
branch: main

View File

@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
# This needs to be bullseye-slim because the Ruby image is built on bullseye-slim
ARG NODE_VERSION="16.19-bullseye-slim"
ARG NODE_VERSION="18.15-bullseye-slim"
FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.1-slim as ruby
FROM node:${NODE_VERSION} as build
@ -59,6 +59,7 @@ RUN bundle exec rails assets:precompile
FROM node:${NODE_VERSION}
ARG SOURCE_TAG=''
ARG UID="991"
ARG GID="991"
@ -102,7 +103,8 @@ COPY --link --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
ENV RAILS_ENV="production" \
NODE_ENV="production" \
RAILS_SERVE_STATIC_FILES="true" \
BIND="0.0.0.0"
BIND="0.0.0.0" \
SOURCE_TAG="${SOURCE_TAG}"
# Set the run user
USER mastodon

View File

@ -21,7 +21,7 @@ module Mastodon
end
def suffix
'+glitch+th'
'+glitch.th'
end
def to_a
@ -42,7 +42,9 @@ module Mastodon
# specify git tag or commit hash here
def source_tag
ENV.fetch('SOURCE_TAG', nil)
tag = ENV.fetch('SOURCE_TAG', nil)
return if tag.nil? || tag.empty?
tag
end
def source_url