Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
monitoring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
monitoring
Commits
6ce11ec2
Commit
6ce11ec2
authored
1 year ago
by
Tibo
Browse files
Options
Downloads
Patches
Plain Diff
deploy
parent
07bbc44b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#12740
passed
1 year ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+24
-0
24 additions, 0 deletions
.gitlab-ci.yml
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
docker-compose.tmpl
+41
-0
41 additions, 0 deletions
docker-compose.tmpl
with
66 additions
and
1 deletion
.gitlab-ci.yml
+
24
−
0
View file @
6ce11ec2
...
...
@@ -62,3 +62,27 @@ build:
-
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-
docker push $CI_REGISTRY_IMAGE:latest
deploy
:
stage
:
deploy
image
:
alpine
before_script
:
# install envsubst and ssh-add
-
apk add gettext openssh-client
script
:
# create the new docker-compose.yml
-
envsubst < docker-compose.tmpl > docker-compose.yml
# start ssh-agent and import ssh private key
-
eval `ssh-agent`
-
ssh-add <(echo "$SSH_PRIVATE_KEY")
# add server to list of known hosts
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
touch ~/.ssh/known_hosts
-
chmod 600 ~/.ssh/known_hosts
-
echo $SSH_HOST_KEY >> ~/.ssh/known_hosts
# upload docker-compose to the server
-
scp docker-compose.yml monitoring@$SERVER:/home/monitoring/
# docker login and restart services
-
ssh monitoring@$SERVER "cd /home/monitoring;
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY;
docker compose up -d"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Dockerfile
+
1
−
1
View file @
6ce11ec2
...
...
@@ -5,7 +5,7 @@
#### Step 1 : composer
FROM
cylab/php
7
4
AS
composer
FROM
cylab/php
:7.
4
AS
composer
COPY
. /var/www/html
WORKDIR
/var/www/html
...
...
This diff is collapsed.
Click to expand it.
docker-compose.tmpl
0 → 100644
+
41
−
0
View file @
6ce11ec2
#
# docker-compose.tmpl
# https://cylab.be/blog/229/continuous-deployment-with-gitlab-and-docker
# $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
#
version: "3.7"
services:
web:
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
depends_on:
- redis
- mysql
ports:
- "80"
volumes:
- ./volumes/web:/var/www/html/storage
restart: "unless-stopped"
environment:
WAIT_HOSTS: mysql:3306
env_file: env
labels:
- traefik.http.routers.amc.rule=Host(`monitoring.cylab.be`)
- traefik.http.routers.amc.tls=true
- traefik.http.routers.amc.tls.certresolver=letsencrypt
redis:
image: redis:4-alpine
volumes:
- ./volumes/redis:/data
restart: "unless-stopped"
mysql:
image: mysql:5.7
volumes:
- ./volumes/mysql:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
restart: "unless-stopped"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment