-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
55 lines (51 loc) · 2.5 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
stages:
- build
- deploy
build:api_server:
stage: build
image: "rust:latest"
script:
- rustup toolchain install nightly
- cargo +nightly build --release
# artifacts make sure the build binary can
# be reached from later jobs.
artifacts:
paths:
- target/release/probe-similarity
expire_in: 1 hour
# Files are created by BigQuery, then copied to
# Google Cloud Storage. We'll copy from there
# into the gitlab-runner
build:current_gcloud_files:
stage: build
image: "google/cloud-sdk"
script:
- mkdir -p bq_data
# Get the most current files, which are two days behind in numbering (well, for now)
# TODO: This some very brittle thing that needs to be improved upon.
- echo "$GCP_SERVICE_KEY" > gcloud-service-key.json # Google Cloud service accounts
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- let tday=`date +"%d"`-2; gsutil -m cp gs://ripencc_rnd_processes/jaccard/jaccard_similarity_ipv4_`date +"%Y-%m"`-${tday}_* ./bq_data
# artifacts make sure the build binary can
# be reached from later jobs.
artifacts:
paths:
- bq_data/
expire_in: 1 hour
deploy_server:
stage: deploy
script:
- echo "$AWS_EC2_PEM" > atlas-probesim-dev.pem
- chmod 0400 atlas-probesim-dev.pem
- scp -o StrictHostKeyChecking=no -o IdentityFile=atlas-probesim-dev.pem target/release/probe-similarity ubuntu@ec2-52-59-192-252.eu-central-1.compute.amazonaws.com:/home/ubuntu/probe-similarity-new
- scp -ro StrictHostKeyChecking=no -o IdentityFile=atlas-probesim-dev.pem ./bq_data ubuntu@ec2-52-59-192-252.eu-central-1.compute.amazonaws.com:/home/ubuntu/
# make sure to allow the `ubuntu` user to enter the systemctl commands without interactive authentication, like so:
# %LimitedAdmins ALL=NOPASSWD: /bin/systemctl stop atlas-probesim-api.service
# %LimitedAdmins ALL=NOPASSWD: /bin/systemctl start atlas-probesim-api.service
# in /etc/sudoers
# Also note that the command should be issued as /bin/systemctl (full path)
- ssh -o StrictHostKeyChecking=no -i atlas-probesim-dev.pem ubuntu@ec2-52-59-192-252.eu-central-1.compute.amazonaws.com "sudo /bin/systemctl stop atlas-probesim-api.service && rm /home/ubuntu/probe-similarity && mv /home/ubuntu/probe-similarity-new /home/ubuntu/probe-similarity && sudo /bin/systemctl start atlas-probesim-api.service"
# dependencies make sure the artifacts from former jobs are reachable from this one
dependencies:
- build:api_server
- build:current_gcloud_files