th: streaming builds again?

This commit is contained in:
Kouhai 2024-02-01 10:09:23 -08:00
parent 8fd45df06e
commit f50b12fe6e
3 changed files with 41 additions and 55 deletions

View file

@ -1,6 +1,7 @@
variables: variables:
environment: &docker-environment environment: &docker-environment
NAME: gitea.treehouse.systems/treehouse/mastodon SERVER_IMAGE: gitea.treehouse.systems/treehouse/mastodon
STREAMING_IMAGE: gitea.treehouse.systems/treehouse/mastodon-streaming
DATE_COMMAND: export COMMIT_DATE=$(date -u -Idate -d @$(git show -s --format=%ct)) DATE_COMMAND: export COMMIT_DATE=$(date -u -Idate -d @$(git show -s --format=%ct))
docker-step: &docker-step docker-step: &docker-step
image: docker:rc-git image: docker:rc-git
@ -17,43 +18,18 @@ clone:
depth: 10 depth: 10
pipeline: pipeline:
# build-base:
# <<: *docker-step
# commands:
# - docker version
# - docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . --target build-base -t $NAME:build-base
# build:
# <<: *docker-step
# commands:
# - docker version
# - docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . --target build -t $NAME:build
# output-base:
# <<: *docker-step
# commands:
# - docker version
# - docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . --target output-base -t $NAME:build
# the world is not yet ready for this step
# test:
# <<: *docker-step
# commands:
# - docker run --rm -e RAILS_ENV=test -e NODE_ENV=development $NAME:build-base sh -c 'bundle config set --local without development && bundle install && rake spec'
output: output:
<<: *docker-step <<: *docker-step
commands: commands:
- eval $DATE_COMMAND - eval $DATE_COMMAND
- export TAG=$${COMMIT_DATE}.$CI_COMMIT_SHA && echo $${TAG} - export TAG=$${COMMIT_DATE}.$CI_COMMIT_SHA && echo $${TAG}
- docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $NAME:latest - docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $SERVER_IMAGE:$${TAG}
- docker image build -f streaming/Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $NAME-streaming:latest - docker image build -f streaming/Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $STREAMING_IMAGE:$${TAG}
- docker tag $NAME:latest $NAME:$TAG - docker tag $SERVER_IMAGE:$${TAG} $SERVER_IMAGE:latest
- docker tag $NAME-streaming:latest $NAME-streaming:$TAG - docker tag $STREAMING_IMAGE:$${TAG} $SERVER_IMAGE:latest
# idk what's actually persisted between steps - echo -n > tags.txt
# /shrug this works, so,??? - echo $${TAG} | tee -a tags.txt
- echo $${TAG} > tags.txt - echo latest | tee -a tags.txt
- echo latest >> tags.txt
# maybe we can use tags someday,,, # maybe we can use tags someday,,,
# tag-tag: # tag-tag:
@ -61,7 +37,7 @@ pipeline:
# volumes: # volumes:
# - /var/run/docker.sock:/var/run/docker.sock # - /var/run/docker.sock:/var/run/docker.sock
# commands: # commands:
# - docker tag $NAME:latest $NAME:$CI_COMMIT_TAG # - docker tag $SERVER_IMAGE:latest $SERVER_IMAGE:$CI_COMMIT_TAG
# when: # when:
# event: tag # event: tag
@ -69,10 +45,10 @@ pipeline:
<<: *docker-step <<: *docker-step
commands: commands:
- echo $REGISTRY_SECRET | docker login -u $REGISTRY_USER --password-stdin gitea.treehouse.systems - echo $REGISTRY_SECRET | docker login -u $REGISTRY_USER --password-stdin gitea.treehouse.systems
- cat tags.txt | xargs -n 1 -I% echo docker image push $NAME:% - cat tags.txt | xargs -n 1 -I% echo docker image push $SERVER_IMAGE:%
- cat tags.txt | xargs -n 1 -I% docker image push $NAME:% - cat tags.txt | xargs -n 1 -I% docker image push $SERVER_IMAGE:%
- cat tags.txt | xargs -n 1 -I% echo docker image push $NAME-streaming:% - cat tags.txt | xargs -n 1 -I% echo docker image push $STREAMING_IMAGE:%
- cat tags.txt | xargs -n 1 -I% docker image push $NAME-streaming:% - cat tags.txt | xargs -n 1 -I% docker image push $STREAMING_IMAGE:%
when: when:
event: [push, tag] event: [push, tag]
branch: main branch: main

View file

@ -26,6 +26,8 @@ ARG MASTODON_VERSION_PRERELEASE=""
# Append build metadata or fork information to version.rb [--build-arg MASTODON_VERSION_METADATA="something"] # Append build metadata or fork information to version.rb [--build-arg MASTODON_VERSION_METADATA="something"]
ARG MASTODON_VERSION_METADATA="" ARG MASTODON_VERSION_METADATA=""
ARG SOURCE_TAG=""
# Allow Ruby on Rails to serve static files # Allow Ruby on Rails to serve static files
# See: https://docs.joinmastodon.org/admin/config/#rails_serve_static_files # See: https://docs.joinmastodon.org/admin/config/#rails_serve_static_files
ARG RAILS_SERVE_STATIC_FILES="true" ARG RAILS_SERVE_STATIC_FILES="true"

View file

@ -44,33 +44,41 @@ module Mastodon
end end
def repository def repository
ENV.fetch('GIT_REPOSITORY', false) || ENV.fetch('GITHUB_REPOSITORY', false) || 'treehouse/mastodon' @repository ||= ENV.fetch('GIT_REPOSITORY', false) || ENV.fetch('GITHUB_REPOSITORY', false) || 'treehouse/mastodon'
end end
def source_base_url def source_base_url
base = ENV['GITHUB_REPOSITORY'] ? 'https://github.com' : 'https://gitea.treehouse.systems' @source_base_url ||=
ENV.fetch('SOURCE_BASE_URL', "#{base}/#{repository}") begin
base = ENV['GITHUB_REPOSITORY'] ? 'https://github.com' : 'https://gitea.treehouse.systems'
ENV.fetch('SOURCE_BASE_URL', "#{base}/#{repository}")
end
end end
# specify git tag or commit hash here # specify git tag or commit hash here
def source_tag def source_tag
tag = ENV.fetch('SOURCE_TAG', nil) @source_tag ||=
return if tag.nil? || tag.empty? begin
tag tag = ENV.fetch('SOURCE_TAG', nil)
return if tag.nil? || tag.empty?
tag
end
end end
def source_url def source_url
tag = source_tag @source_url ||=
if tag && source_base_url =~ /gitea/ begin
suffix = if !tag[/\H/] if source_tag && source_base_url =~ /gitea/
"commit/#{tag}" suffix = if !tag[/\H/]
else "commit/#{source_tag}"
"branch/#{tag}" else
end "branch/#{source_tag}"
"#{source_base_url}/#{suffix}" end
else "#{source_base_url}/#{suffix}"
source_base_url else
end source_base_url
end
end
end end
def user_agent def user_agent