Skip to content

Commit

Permalink
Add migrate to deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
danielMoreirad committed Mar 22, 2024
1 parent eec4040 commit 3b5d923
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 33 deletions.
1 change: 1 addition & 0 deletions api/arconnectmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
Expand Down
97 changes: 64 additions & 33 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,83 @@
# Uncomment the following to require manually verifying the host key before first deploy.
# set :ssh_options, verify_host_key: :secure

# Créer un lien symbolique vers le fichier .env dans le répertoire current/backend
after 'deploy:symlink:release', 'deploy:create_env_symlink'
namespace :deploy do
desc 'Create symlink for .env file'
task :create_env_symlink do
on roles(:app) do
execute "ln -sf #{shared_path}/.env #{release_path}/api/.env"
desc 'Create symlink for .env file'
task :create_env_symlink do
on roles(:app) do
execute "ln -sf #{shared_path}/.env #{release_path}/api/.env"
end
end

desc 'Migrate database'
task :migrate_database do
on roles(:app) do
within release_path.join('api') do
execute :python, 'manage.py migrate'
end
end
end

# Installer les dépendances Python
after 'deploy:updating', 'pip:install'
namespace :pip do
desc 'Install'
task :install do
on roles([:app, :web]) do |h|
execute "pip install -r #{release_path}/api/requirements.txt"

end
desc 'Collect static files'
task :collect_static do
on roles(:app) do
within release_path.join('api') do
execute :python, 'manage.py collectstatic --noinput'
end
end
end
end

namespace :pip do
desc 'Install'
task :install do
on roles([:app, :web]) do |h|
execute "pip install -r #{release_path}/api/requirements.txt"
end
end
end


# Construire et déployer l'application Vue.js
after 'deploy:updated', 'vue:deploy'
namespace :vue do
desc 'Build and deploy Vue.js application'
task :deploy do
on roles(:app) do
within release_path.join('frontend') do
execute :npm, 'install' # Installer les dépendances npm
execute :npm, 'run build' # Construire l'application Vue.js
end
desc 'Build and deploy Vue.js application'
task :deploy do
on roles(:app) do
within release_path.join('frontend') do
execute :npm, 'install' # Installer les dépendances npm
execute :npm, 'run build' # Construire l'application Vue.js
end
end
end
end

# Redémarrer le serveur Gunicorn
after 'deploy:publishing', 'gunicorn:restart'
namespace :gunicorn do
desc 'Restart application'
task :restart do
on roles(:web) do |h|
execute :sudo, 'systemctl restart gunicorn'
end
end
desc 'Stop application'
task :stop do
on roles(:app) do
execute :sudo, 'systemctl stop gunicorn'
end
end

desc 'Restart application'
task :restart do
on roles(:app) do
execute :sudo, 'systemctl restart gunicorn'
end
end
end

# Créer un lien symbolique vers le fichier .env dans le répertoire current/backend
after 'deploy:symlink:release', 'deploy:create_env_symlink'

# Installer les dépendances Python
after 'deploy:updating', 'pip:install'

# Construire et déployer l'application Vue.js
after 'deploy:updated', 'vue:deploy'

# Redémarrer le serveur Gunicorn
after 'deploy:publishing', 'gunicorn:stop'
after 'gunicorn:stop', 'gunicorn:restart'

# Après le redémarrage de Gunicorn, exécutez les migrations de la base de données et collectez les fichiers statiques
after 'gunicorn:restart', 'deploy:migrate_database'
after 'gunicorn:restart', 'deploy:collect_static'

0 comments on commit 3b5d923

Please sign in to comment.