mirror of
https://github.com/czhu12/canine.git
synced 2025-12-17 00:44:33 -06:00
allow separate container registry url in projects
This commit is contained in:
@@ -96,7 +96,8 @@ class ProjectsController < ApplicationController
|
||||
:cluster_id,
|
||||
:docker_build_context_directory,
|
||||
:docker_command,
|
||||
:dockerfile_path
|
||||
:dockerfile_path,
|
||||
:container_registry_url
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,7 +86,7 @@ class Projects::BuildJob < ApplicationJob
|
||||
end
|
||||
|
||||
def push_to_dockerhub(project, build)
|
||||
docker_push_command = [ "docker", "push", "ghcr.io/#{project.repository_url}:latest" ]
|
||||
docker_push_command = [ "docker", "push", project.container_registry_url ]
|
||||
|
||||
build.info("Pushing Docker image to #{docker_push_command.last}", color: :yellow)
|
||||
stdout, stderr, status = Open3.capture3(*docker_push_command)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# id :bigint not null, primary key
|
||||
# autodeploy :boolean default(TRUE), not null
|
||||
# branch :string default("main"), not null
|
||||
# container_registry_url :string
|
||||
# docker_build_context_directory :string default("."), not null
|
||||
# docker_command :string
|
||||
# dockerfile_path :string default("./Dockerfile"), not null
|
||||
@@ -92,7 +93,8 @@ class Project < ApplicationRecord
|
||||
end
|
||||
|
||||
def container_registry_url
|
||||
"ghcr.io/#{repository_url}:latest"
|
||||
container_registry = self.attributes["container_registry_url"] || repository_url
|
||||
"ghcr.io/#{container_registry}:latest"
|
||||
end
|
||||
|
||||
def deployable?
|
||||
|
||||
@@ -58,6 +58,13 @@
|
||||
<%= form.text_field :predeploy_command, class: "input input-bordered w-full focus:outline-offset-0" %>
|
||||
</div>
|
||||
|
||||
<div class="form-control my-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Container registry URL</span>
|
||||
</label>
|
||||
<%= form.text_field :container_registry_url, class: "input input-bordered w-full focus:outline-offset-0" %>
|
||||
</div>
|
||||
|
||||
<div class="form-footer">
|
||||
<%= form.button "Submit", class: "btn btn-primary" %>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= form_with(model: project) do |form| %>
|
||||
<%= render "shared/error_messages", resource: form.object %>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Name</span>
|
||||
</label>
|
||||
@@ -12,7 +12,7 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Cluster</span>
|
||||
</label>
|
||||
@@ -22,7 +22,7 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Github Repository</span>
|
||||
</label>
|
||||
@@ -36,7 +36,7 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Branch</span>
|
||||
</label>
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
|
||||
<% unless Rails.application.config.local_mode %>
|
||||
<div class="form-control w-full max-w-xs rounded-lg bg-base-200 p-2 px-4">
|
||||
<div class="form-control w-full max-w-sm rounded-lg bg-base-200 p-2 px-4">
|
||||
<label class="label mt-1">
|
||||
<span class="label-text cursor-pointer">Autodeploy</span>
|
||||
<%= form.check_box :autodeploy, class: "checkbox" %>
|
||||
@@ -55,7 +55,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Dockerfile path</span>
|
||||
</label>
|
||||
@@ -65,27 +65,34 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Docker build context directory</span>
|
||||
</label>
|
||||
<%= form.text_field :docker_build_context_directory, class: "input input-bordered w-full focus:outline-offset-0" %>
|
||||
</div>
|
||||
|
||||
<div class="form-control mt-1 w-full max-w-xs">
|
||||
<div class="form-control mt-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Docker command</span>
|
||||
</label>
|
||||
<%= form.text_field :docker_command, class: "input input-bordered w-full focus:outline-offset-0" %>
|
||||
</div>
|
||||
|
||||
<div class="form-control my-1 w-full max-w-xs">
|
||||
<div class="form-control my-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Predeploy command</span>
|
||||
</label>
|
||||
<%= form.text_field :predeploy_command, class: "input input-bordered w-full focus:outline-offset-0" %>
|
||||
</div>
|
||||
|
||||
<div class="form-control my-1 w-full max-w-sm">
|
||||
<label class="label">
|
||||
<span class="label-text">Container registry URL</span>
|
||||
</label>
|
||||
<%= form.text_field :container_registry_url, class: "input input-bordered w-full focus:outline-offset-0", value: "" %>
|
||||
</div>
|
||||
|
||||
<div class="form-footer">
|
||||
<%= form.button "Submit", class: "btn btn-primary" %>
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddContainerRegistryUrlToProjects < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
add_column :projects, :container_registry_url, :string
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_12_23_041419) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_01_02_003342) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -257,6 +257,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_23_041419) do
|
||||
t.integer "status", default: 0, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "container_registry_url"
|
||||
t.index ["cluster_id"], name: "index_projects_on_cluster_id"
|
||||
t.index ["name"], name: "index_projects_on_name", unique: true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user