Skip to content

Commit a09c81a

Browse files
author
Pablo Panero
committed
deployment: image building and registries
1 parent 70ef0e1 commit a09c81a

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed

docs/deployment/image.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build your instance Docker image
2+
3+
In this section you will learn to build the docker image of your InvenioRDM instance! Doing so is as simple as running the following command:
4+
5+
``` console
6+
docker build -t demo-inveniordm /path/to/your/instance --build-arg include_assets=true
7+
```
8+
9+
!!! info "Tag name"
10+
In this case we have chosen to call our image `demo-inveniordm`, but you can choose your own name.
11+
12+
**Why is the `include_assets` flag needed**
13+
14+
When running InvenioRDM in local (`invenio-cli run`) you are running the uWSGI server in your own machine. On the other hand, when running `invenio-cli containerize` you are building the docker image. Then you are runing it in your machine along the other containers. Nonetheless, the statics are built in a different fashion. However, when deploying somewhere else they are needed.
15+
16+
This is the case when deploying in OpenShift. To solve this problem the charts define a share volume mounted on the Nginx and the Web containers.
17+
18+
When a volume is mounted it overwrites the contents of the folder (i.e. it will delete the assets). Therefore, we make use of an `initContainer` to mount the volume in a temporary location and copy to the volume the assets. This way when the volume is mounted into Nginx and Web containers it already has the assets. Being the end result that `/static` files can be served directly by Nginx.

docs/deployment/openshift.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ worker:
7878
image: your/invenio-image
7979
```
8080
81+
!!! info "Image registries"
82+
You can get to know more about where and how to store you instance's docker image [here](./registries).
83+
8184
The next step is the installation itself, with your own configuration in the `values.yaml`. If you added the repository, you can install it by using the chart name and the desired version:
8285

8386
``` console

docs/deployment/registries.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Image registries
2+
3+
There are several places where you can store your docker image. In this section, we cover some of the most known ones.
4+
However, you can use any other of your preference.
5+
6+
!!! warning "Build your image before hand"
7+
In the following documentation we are assuming that you have already built your docker image.
8+
You can find documentation on how to do it [here](./image.md).
9+
10+
## DockerHub
11+
12+
To use docker hub, follow Docker's [official documentation](https://docs.docker.com/docker-hub/repos/).
13+
14+
## GitHub
15+
16+
To store your image in GitHub you will need a repository. You can use your instance's one. For example:
17+
*https://github/yourusername/rdmrepo*. In addition, you will need to [create an access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). This access token must have
18+
`read:packages` and `write:packages` scopes.
19+
20+
The first step is to login in GitHub's docker registry:
21+
22+
``` console
23+
$ docker login docker.pkg.github.com -u <YOU_GITHUB_USERNAME> -p <YOUR_GITHUB_TOKEN>
24+
```
25+
26+
Then find your docker image and tag it you the url of your GitHub registry:
27+
28+
```
29+
$ docker images
30+
REPOSITORY TAG IMAGE ID CREATED SIZE
31+
demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB
32+
33+
$ docker tag demo-inveniordm docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest
34+
```
35+
36+
!!! info "Project name"
37+
Note that `rdmrepo` is the name of your GitHub repository. Therefore the tag is: ``docker.pkg.github.co/<your_github_user_name>/<your_github_repo_name>/<your_image_name>:<version>``
38+
39+
Check that it was tagged correctly:
40+
41+
``` console
42+
$ docker images
43+
REPOSITORY TAG IMAGE ID CREATED SIZE
44+
demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB
45+
docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest latest 9b6dd5ae6b48 17 hours ago 2.33GB
46+
```
47+
48+
The last step is to push your package to the github registry:
49+
50+
``` console
51+
docker push docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest
52+
```
53+
54+
In order to use this image, you must set the following value in your `values.yaml` file (for both `web` and `worker`):
55+
56+
```
57+
image: docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest
58+
```
59+
60+
Even if your project and/or image is public, GitHub requires you to be authenticated in order to pull your image.
61+
In OpenShift you can change the default pulling configuration so that it uses your token. You can do so as follows:
62+
63+
``` console
64+
$ oc create secret docker-registry <SECRET_NAME> \
65+
--docker-server=docker.pkg.github.com \
66+
--docker-username=<YOUR_GITHUB_USERNAME> \
67+
--docker-password=<YOUR_GITHUB_PASSWORD>
68+
$ oc secrets link default <SECRET_NAME> --for=pull \
69+
--namespace=<YOUR_OPENSHIFT_PROJECT_NAME>
70+
```
71+
72+
## OpenShift
73+
74+
First you need to login in your OpenShift cluster and its image registry:
75+
76+
``` console
77+
$ docker login -u openshift -p $(oc whoami -t) <registry_ip>:<port>
78+
$ oc login
79+
$ oc project
80+
Using project "inveniordm" on server "<registry_ip>:<port>".
81+
```
82+
83+
Then find your docker image and tag it you the url of your OpenShift registry:
84+
85+
``` console
86+
$ docker images
87+
REPOSITORY TAG IMAGE ID CREATED SIZE
88+
demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB
89+
90+
$ docker tag demo-inveniordm <registry_ip>:<port>/inveniordm/demo-inveniordm:latest
91+
```
92+
93+
!!! info "Project name"
94+
Note that `inveniordm` is the name of the OpenShift project we are using. It's value should be the one returned
95+
by the `oc project` command. Therefore the tag is: ``<registry_ip>:<port>/<project_name>/<name_of_your_image>:<version>``
96+
97+
Check that it was tagged correctly:
98+
99+
``` console
100+
$ docker images
101+
REPOSITORY TAG IMAGE ID CREATED SIZE
102+
demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB
103+
<registry_ip>:<port>/inveniordm/demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB
104+
```
105+
106+
Finally push it to the image registry of OpenShift:
107+
108+
``` console
109+
$ docker push <registry_ip>:<port>/inveniordm/demo-inveniordm:latest
110+
```
111+
112+
In order to use this image, you must set the following value in your `values.yaml` file (for both `web` and `worker`):
113+
114+
``` console
115+
image: <registry_ip>:<port>/inveniordm/demo-inveniordm:rdm
116+
```

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ nav:
4848
- Kubernetes: 'deployment/kubernetes.md'
4949
- System components: 'deployment/services.md'
5050
- Configuration: 'deployment/configuration.md'
51+
- Building your image: 'deployment/image.md'
52+
- Image registries: 'deployment/registries.md'
5153
- Benchmarking: 'deployment/benchmark.md'
5254

5355

0 commit comments

Comments
 (0)