Skip to content

Commit

Permalink
Fix stack run notification (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Nov 26, 2024
1 parent fe8c1f6 commit f175b16
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 35 deletions.
26 changes: 7 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ RUN ls -al

COPY --from=node /app/build ./priv/static

RUN \
mkdir -p /opt/built && \
mix distillery.release --name ${APP_NAME} && \
cp _build/${MIX_ENV}/rel/${APP_NAME}/releases/*/${APP_NAME}.tar.gz /opt/built && \
cd /opt/built && \
tar -xzf ${APP_NAME}.tar.gz && \
rm ${APP_NAME}.tar.gz
RUN mix release

FROM alpine:3.17.1 as tools

Expand Down Expand Up @@ -93,11 +87,7 @@ RUN apk add --update --no-cache curl ca-certificates unzip wget openssl build-ba
chmod +x /usr/local/bin/terraform

# From this line onwards, we're in a new image, which will be the image used in production
FROM erlang:24.3.4.6-alpine

ARG CLOUD_SDK_VERSION=273.0.0
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH
FROM alpine:latest

COPY --from=tools /usr/local/bin/plural /usr/local/bin/plural
COPY --from=tools /usr/local/bin/helm /usr/local/bin/helm
Expand All @@ -106,8 +96,6 @@ COPY --from=tools /usr/local/bin/kubectl /usr/local/bin/kubectl

RUN apk --no-cache add \
ca-certificates \
python3 \
py3-pip \
# py-crcmod \
curl \
bash \
Expand All @@ -117,8 +105,7 @@ RUN apk --no-cache add \
git \
gnupg

RUN apk add --no-cache --update --virtual=build gcc musl-dev python3-dev libffi-dev openssl-dev cargo make && \
pip3 install --no-cache-dir --prefer-binary azure-cli && \
RUN apk add --no-cache --update --virtual=build gcc musl-dev libffi-dev openssl-dev make && \
apk del build

# The name of your application/release (required)
Expand All @@ -129,7 +116,8 @@ ENV REPLACE_OS_VARS=true \
APP_NAME=${APP_NAME} \
GIT_ASKPASS=/opt/app/bin/.git-askpass \
SSH_ASKPASS=/opt/app/bin/.ssh-askpass \
GIT_COMMIT=${GIT_COMMIT}
GIT_COMMIT=${GIT_COMMIT} \
MIX_ENV=prod

WORKDIR /opt/app

Expand Down Expand Up @@ -157,6 +145,6 @@ ENV GIT_SSH_COMMAND="ssh -i /root/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o
SSH_ASKPASS_REQUIRE=force \
DISPLAY=1

COPY --from=builder /opt/built .
COPY --from=builder /opt/app/_build/prod/rel/console .

CMD trap 'exit' INT; eval $(ssh-agent -s); /opt/app/bin/${APP_NAME} foreground
CMD trap 'exit' INT; eval $(ssh-agent -s); /opt/app/bin/console start
2 changes: 1 addition & 1 deletion charts/console-rapid/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: console-rapid
description: rapid channel chart for the plural console (used for testing)
appVersion: 0.10.40
version: 0.3.71
version: 0.3.72
dependencies:
- name: kas
version: 0.1.0
Expand Down
3 changes: 2 additions & 1 deletion charts/console/templates/migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ spec:
{{- toYaml .Values.migrator.containerSecurityContext | nindent 10 }}
{{ end }}
image: "{{ .Values.global.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
command: ["/opt/app/bin/console", "migrate"]
command:
{{ toYaml .Values.migrator.command | nindent 10 }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- secretRef:
Expand Down
3 changes: 2 additions & 1 deletion charts/console/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ homeDir: /root
podLabels: {}
podAnnotations: {}

migrator: {}
migrator:
command: ["/opt/app/bin/console", "migrate"]

console:
additionalContainers: ~
Expand Down
5 changes: 5 additions & 0 deletions lib/console/schema/pr_automation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ defmodule Console.Schema.PrAutomation do
|> put_new_change(:create_policy_id, &Ecto.UUID.generate/0)
|> validate_required([:name, :title, :message, :connection_id])
|> unique_constraint(:name)
|> foreign_key_constraint(:promotion_criteria,
name: :promotion_criteria,
match: :prefix,
message: "Cannot delete due to a pipeline requiring this pr automation"
)
|> foreign_key_constraint(:cluster_id)
|> foreign_key_constraint(:service_id)
|> foreign_key_constraint(:connection_id)
Expand Down
2 changes: 1 addition & 1 deletion lib/console/services/users.ex
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ defmodule Console.Services.Users do
|> add_operation({:group, group}, fn _ ->
case get_group_by_name(group) do
%Group{} = group -> {:ok, group}
nil -> create_group(%{name: group, description: "synced from Plural"})
nil -> create_group(%{name: group, description: "synced from your OpenId Connect provider by Plural"})
end
end)
|> add_operation({:member, group}, fn %{user: user} = results ->
Expand Down
17 changes: 12 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ defmodule Console.MixProject do
compilers: Mix.compilers(),
start_permanent: Mix.env() == :prod,
deps: deps(),
aliases: aliases()
aliases: aliases(),
releases: [
console: [
include_executables_for: [:unix],
runtime_config_path: "rel/runtime.exs",
applications: [
runtime_tools: :permanent,
console: :permanent
]
]
]
]
end

Expand All @@ -70,7 +80,6 @@ defmodule Console.MixProject do
[
{:ecto, "~> 3.9.0", override: true},
{:ex_machina, "~> 2.3", only: :test},
{:distillery, "~> 2.1"},
{:libcluster, "~> 3.2"},
{:ex_aws, "~> 2.1"},
{:ex_aws_sts, "~> 2.3.0"},
Expand Down Expand Up @@ -105,7 +114,6 @@ defmodule Console.MixProject do
{:uniq, "~> 0.4"},
{:mix_audit, "~> 2.0", only: [:dev, :test], runtime: false},
{:sobelow, "~> 0.8", only: [:dev, :test]},
{:porcelain, "~> 2.0"},
{:absinthe, "~> 1.7.5"},
{:absinthe_relay, "~> 1.5.2"},
{:absinthe_plug, "~> 1.5", git: "https://github.com/absinthe-graphql/absinthe_plug.git", commit: "3a984cc341ebb32c79e7ae58b4ebd116d5c62f9e", override: true},
Expand All @@ -115,7 +123,6 @@ defmodule Console.MixProject do
{:timex, "~> 3.7"},
{:quantum, "~> 3.0"},
{:swarm, "~> 3.0"},
{:bandit, "~> 1.0"},
{:yaml_elixir, "~> 2.9"},
{:google_api_ai_platform, "~> 0.22.0"},
{:goth, "~> 1.4", git: "https://github.com/pluralsh/goth.git", branch: "plrl-cleanup", commit: "4958159d1e9acec2154590ecacc732ecd58f8312"},
Expand All @@ -140,7 +147,7 @@ defmodule Console.MixProject do
{:deep_merge, "~> 1.0"},
{:ymlr, "~> 2.0"},
{:remote_ip, "~> 0.2.0"},
{:erlsom, "~> 1.4"},
{:erlsom, "~> 1.5.1"},
{:inflex, "~> 2.0.0"},
{:websockex, "~> 0.4.3"},
{:briefly, "~> 0.5.0"},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ecto_sql": {:hex, :ecto_sql, "3.9.2", "34227501abe92dba10d9c3495ab6770e75e79b836d114c41108a4bf2ce200ad5", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1eb5eeb4358fdbcd42eac11c1fbd87e3affd7904e639d77903c1358b2abd3f70"},
"elixir_make": {:hex, :elixir_make, "0.6.1", "8faa29a5597faba999aeeb72bbb9c91694ef8068f0131192fb199f98d32994ef", [:mix], [], "hexpm", "35d33270680f8d839a4003c3e9f43afb595310a592405a00afc12de4c7f55a18"},
"elixpath": {:git, "https://github.com/mtannaan/elixpath.git", "78d301bb82f8bd74a120399f16b905b9a4b25468", []},
"erlsom": {:hex, :erlsom, "1.5.0", "c5a5cdd0ee0e8dca62bcc4b13ff08da24fdefc16ccd8b25282a2fda2ba1be24a", [:rebar3], [], "hexpm", "55a9dbf9cfa77fcfc108bd8e2c4f9f784dea228a8f4b06ea10b684944946955a"},
"erlsom": {:hex, :erlsom, "1.5.1", "c8fe2babd33ff0846403f6522328b8ab676f896b793634cfe7ef181c05316c03", [:rebar3], [], "hexpm", "7965485494c5844dd127656ac40f141aadfa174839ec1be1074e7edf5b4239eb"},
"ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"},
"evel": {:hex, :evel, "0.1.2", "11f232a098f7ed31adb12935e5690819c1617b7d4cb11424b0e554c348c15cab", [:rebar3], [{:hash_ring, "~>0.4.0", [hex: :hash_ring, repo: "hexpm", optional: false]}], "hexpm", "1d6808bb60415572ef13cd085adf2f3266a3eaa2e810d7d3e095d1364b4d8032"},
"ex_aws": {:hex, :ex_aws, "2.5.6", "6f642e0f82eff10a9b470044f084b81a791cf15b393d647ea5f3e65da2794e3d", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8 or ~> 3.0", [hex: :jsx, repo: "hexpm", optional: true]}, {:mime, "~> 1.2 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:req, "~> 0.3", [hex: :req, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c69eec59e31fdd89d0beeb1d97e16518dd1b23ad95b3d5c9f1dcfec23d97f960"},
Expand Down
6 changes: 3 additions & 3 deletions priv/notifications/slack/stack.run.json.eex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "section",
"text": {
"type": "mrkdwn",
"text": "🚀 *The <%= @stack_run.stack.name %> stack has an updated run* "
"text": "🚀 *The <%= @stack_run.stack.name %> stack has an updated run*"
}
},
{
Expand All @@ -28,7 +28,7 @@
},
{
"type": "text",
"url": "<%= @stack_run.repository.url %>\n"
"text": "<%= @stack_run.repository.url %>\n"
},
{
"type": "text",
Expand All @@ -54,7 +54,7 @@
},
{
"type": "text",
"url": "<%= @stack_run.git.folder %>"
"text": "<%= @stack_run.git.folder %>"
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions rel/overlays/bin/migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -eu

cd -P -- "$(dirname -- "$0")"
exec ./console eval "Piazza.Ecto.ReleaseTasks.seed([])"
Loading

0 comments on commit f175b16

Please sign in to comment.