Skip to content

Commit

Permalink
refactor: avoid contract redeployment on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci committed Jan 15, 2025
1 parent 02ac227 commit de68e3a
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ job "{{ job.name }}" {
{% endfor %}
}

volume "data-volume" {
type = "host"
source = "data-volume"
read_only = false
}

task "contracts" {
driver = "exec"

Expand All @@ -63,6 +69,12 @@ job "{{ job.name }}" {
}
{% endif %}

volume_mount {
volume = "data-volume"
destination = "/local/data"
read_only = false
}

{% for port_name in job.ports[0] %}
service {
name = "{{ job.name }}"
Expand Down Expand Up @@ -132,7 +144,12 @@ job "{{ job.name }}" {
{{- end }}
{% endraw %}

{%- if job.artifacts | selectattr('keystores', 'defined') | list | length > 0 %}
if [ -f /local/data/www/contracts.json ]; then
exec python3 -m http.server {{ job.ports[0]['http']['static'] }} --directory /local/data/www
exit $?
fi

{% if job.artifacts | selectattr('keystores', 'defined') | list | length > 0 %}
mkdir -p "${KEYSTORE_DIR}" > /dev/null 2>&1
{%- raw %}
{{- with secret "secret/data/mev-commit" }}
Expand Down Expand Up @@ -269,10 +286,10 @@ job "{{ job.name }}" {

{%- endif %}

mkdir -p /local/www > /dev/null 2>&1
jq -s 'add' local/*_addresses.json > local/www/contracts.json
mkdir -p /local/data/www > /dev/null 2>&1
jq -s 'add' local/*_addresses.json > local/data/www/contracts.json

exec python3 -m http.server {{ job.ports[0]['http']['static'] }} --directory /local/www
exec python3 -m http.server {{ job.ports[0]['http']['static'] }} --directory /local/data/www
# endtodo
EOH
destination = "local/run.sh"
Expand Down

0 comments on commit de68e3a

Please sign in to comment.