This repository contains all our scripts and configuration files necessary for custom deployment on our METANET server.
The server-apps repo is currently located on the server under the user swo
in the folder apps
. This repo needs to be pulled manually in case of changes. There is no CI/CD yet. This repo provides various hooks which get called when one might push a repo onto the server. See git
folder under the user swo
. To trigger a deploy without semaphore, use the following steps in case of dev/develop:
ssh-copy-id swo@stiftungswo.ch
git remote add metanet-develop swo@stiftungswo.ch:~/git/better-dime/develop.git
git push -f metanet-develop dev:master
# => build starts...
The container environment file is stored on the server in the app
folder but not commited for security reasons.
- iZivi
- Dime
- LimeSurvey
- NextCloud
- Traefik ReverseProxy
- Rocket Chat
Directory | Meaning |
---|---|
sites/[project]/[environment] |
Contains all deployment and running configuration for each project and each environment. |
dsl/ |
Code required to support custom DSL |
hooks/ |
Git hooks inserted into each project to connect to custom deployment code |
traefik/ |
Configuration files required to have reverse proxy working |
The CD pushes to the corresponding git repo on the server. The repo has linked the pre-receive hook with the hook stored in this repo. The hook then infers the project and environment depending on the repo to which was pushed to and then calls the deploy
and run
rake task.
Access the metanet server as root or the swo user via ssh. Run rake -T
in the apps
folder to display all potential rake tasks. Then run whichever one needed to restart, stop or deploy a given application: eg. rake traefik:master:restart
When there is a Deployfile in the project-environment folder, there is a rake project:environment:deploy task to execute that Deployfile.
This Task should only be run by the pre-receive hook
When there is a Runfile in the project-environment folder, there is a rake project:environment:run task to execute that Runfile
When there is a Stopfile in the project-environment folder, there is a rake project:environment:stop task to execute that Stopfile
When there is a Runfile and Stopfile in the project-environment folder, there is a rake project:environment:restart task to execute that Stopfile and then that Runfile
Builds an image with SWO naming convention.
Usage:
build_swo_image(
docker_name_supplement: 'name supplement e.g. frontend', # Optional
...[additional build arguments]
)
Produces an image built from the current prod.Dockerfile
inferred from current working directory.
Naming will be swo/[project name]_[supplement]:[environment]
. Environment tags are used to support caching across multiple project instances (only if they differ marginally from each other).
Returns a container name using SWO naming convention based on the project name and environment.
Usage:
swo_container_name(
'supplement e.g. frontend' # Optional
)
Returns a string following the format [project_name]_[environment]_[supplement]
, e.g. better_dime_develop_frontend
Returns an image name using SWO naming convention based on the project name and environment.
Usage:
swo_image_name(
'supplement e.g. frontend' # Optional
)
Returns a string following the format swo/[project_name]_[supplement]:[environment]
, e.g. swo/better_dime_frontend:develop
Stops the running container using the same image and starts a new instance.
Usage:
start_swo_docker_image(
docker_name_supplement: 'supplement e.g. frontend', # Optional
...[additional run flags]
)
Migrates a Rails database
Usage:
migrate_swo_rails_db(
'naming supplement of the rails container e.g. api' # Optional
)
Migrates a Laravel database
Usage:
migrate_swo_laravel_db(
'naming supplement of the rails container e.g. api' # Optional
)
Loads the specified environment file into ENV
.
Usage:
load_environment_file(
'.env file path' # Optional
)
If path is nil
a .env
file will be searched in the current working directory.
Returns the path of the default .env
file, which basically is $(pwd)/.env
Usage:
default_env_file()
Runs a given rake task