add docker doc
This commit is contained in:
parent
bd428ccb7a
commit
d2c74fe16f
6 changed files with 73 additions and 1 deletions
10
README.md
10
README.md
|
@ -10,6 +10,7 @@ dda-devops-build provide a envioronment to tie several DevOps tools together for
|
|||
* terraform v0.11, v0.12 supporting
|
||||
* local file backends
|
||||
* s3 backends
|
||||
* docker / dockerhub
|
||||
* user / team credentials managed by gopass
|
||||
* dda-pallet
|
||||
|
||||
|
@ -18,7 +19,7 @@ dda-devops-build provide a envioronment to tie several DevOps tools together for
|
|||
```
|
||||
sudo apt install python3-pip
|
||||
sudo pip3 install pip3 --upgrade --user
|
||||
pip3 install --pre pybuilder ddadevops deprecation --user
|
||||
pip3 install pybuilder ddadevops deprecation --user
|
||||
export PATH=$PATH:~/.local/bin
|
||||
|
||||
# in case of using terraform
|
||||
|
@ -160,6 +161,13 @@ def access(project):
|
|||
build.get_mfa_session()
|
||||
```
|
||||
|
||||
## Feature DdaDockerBuild
|
||||
|
||||
The docker build supports image building, tagging, testing and login to dockerhost.
|
||||
For bash based builds we support often used script-parts as predefined functions [see install_functions.sh](src/main/resources/docker/image/resources/install_functions.sh).
|
||||
|
||||
A full working example: [doc/example/50_docker_module](doc/example/50_docker_module)
|
||||
|
||||
# Releasing and updating
|
||||
## Publish snapshot
|
||||
|
||||
|
|
42
doc/example/50_docker_module/build.py
Normal file
42
doc/example/50_docker_module/build.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from pybuilder.core import task, init
|
||||
from ddadevops import *
|
||||
|
||||
name = 'example-project'
|
||||
MODULE = 'docker-module'
|
||||
PROJECT_ROOT_PATH = '../../..'
|
||||
|
||||
class MyBuild(DevopsDockerBuild):
|
||||
pass
|
||||
|
||||
@init
|
||||
def initialize(project):
|
||||
project.build_depends_on('ddadevops>=0.6.0')
|
||||
stage = 'prod'
|
||||
dockerhub_user = gopass_field_from_path('your-credential-path', 'login')
|
||||
dockerhub_password = gopass_password_from_path('your-credential-path')
|
||||
config = create_devops_docker_build_config(
|
||||
stage, PROJECT_ROOT_PATH, MODULE, dockerhub_user, dockerhub_password)
|
||||
build = MyBuild(project, config)
|
||||
build.initialize_build_dir()
|
||||
|
||||
|
||||
@task
|
||||
def image(project):
|
||||
build = get_devops_build(project)
|
||||
build.image()
|
||||
|
||||
@task
|
||||
def drun(project):
|
||||
build = get_devops_build(project)
|
||||
build.drun()
|
||||
|
||||
@task
|
||||
def publish(project):
|
||||
build = get_devops_build(project)
|
||||
build.dockerhub_login()
|
||||
build.dockerhub_publish()
|
||||
|
||||
@task
|
||||
def test(project):
|
||||
build = get_devops_build(project)
|
||||
build.test()
|
1
doc/example/50_docker_module/image/Dockerfile
Normal file
1
doc/example/50_docker_module/image/Dockerfile
Normal file
|
@ -0,0 +1 @@
|
|||
FROM ubuntu:18.04
|
13
doc/example/50_docker_module/image/resources/install.sh
Executable file
13
doc/example/50_docker_module/image/resources/install.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
function main() {
|
||||
|
||||
upgradeSystem
|
||||
|
||||
# do some stuff
|
||||
|
||||
cleanupDocker
|
||||
}
|
||||
|
||||
source /tmp/resources/install_functions.sh
|
||||
main
|
7
doc/example/50_docker_module/test/Dockerfile
Normal file
7
doc/example/50_docker_module/test/Dockerfile
Normal file
|
@ -0,0 +1,7 @@
|
|||
FROM docker-module
|
||||
RUN curl -L -o /tmp/serverspec.jar \
|
||||
https://github.com/DomainDrivenArchitecture/dda-serverspec-crate/releases/download/1.3.4/dda-serverspec-standalone.jar
|
||||
|
||||
COPY serverspec.edn /tmp/serverspec.edn
|
||||
|
||||
RUN java -jar /tmp/serverspec.jar /tmp/serverspec.edn -v
|
1
doc/example/50_docker_module/test/serverspec.edn
Normal file
1
doc/example/50_docker_module/test/serverspec.edn
Normal file
|
@ -0,0 +1 @@
|
|||
{:file [{:path "/tmp/resources" :exits false}]}
|
Loading…
Reference in a new issue