1
1
2
- Setup the Devcontainer
3
- ======================
2
+ Setup a Devcontainer
3
+ ====================
4
4
5
5
Introduction
6
6
------------
7
7
8
- The devcontainer provides the environment in which you will do all your development
9
- and management of IOCs.
8
+ The devcontainer provides the environment in which you will do all your development.
9
+ This is a basic tutorial that introduces the concept in preparation for the
10
+ epics devcontainer tutorial.
10
11
11
- The base container is defined in https://github.com/epics-containers/dev-e7
12
- but we will use a customizable image derived from that. The customizable
13
- container definition is in https://github.com/epics-containers/.devcontainer.
12
+ .. seealso :: `epics_devcontainer`
14
13
15
14
16
15
Configure Visual Studio Code
17
16
----------------------------
18
17
18
+ You must ensure you have the devcontainer plugin:
19
+
20
+
21
+ .. figure :: ../images/dev-container-plugin.png
22
+ :width: 600px
23
+ :align: center
24
+
25
+ devcontainer plugin
26
+
27
+
19
28
For podman users, you must first tell VSCode to use podman instead of docker.
20
29
Open a VSCode window and hit "ctrl ," (control-comma) to open the user
21
30
settings editor and search for
22
31
"dev.containers.dockerPath", change its value from "docker" to "podman".
23
32
24
33
25
- Launching the Devcontainer
26
- --------------------------
34
+ .. figure :: ../images/dev-container-settings.png
35
+ :width: 600px
36
+ :align: center
27
37
28
- To setup your devcontainer, perform the following steps:
38
+ devcontainer podman setting
29
39
30
- - create a workspace folder
31
- - clone the .devcontainer repository into the workspace folder
32
- - open the workspace folder with Visual Studio Code.
33
40
34
- for example:
41
+ Launching the Devcontainer
42
+ --------------------------
43
+
44
+ If your repository contains a ``.devcontainer `` directory, vscode will be
45
+ able to follow the instructions inside and launch a container.
35
46
36
47
.. code-block :: bash
37
48
38
- mkdir work-ec
39
- cd work-ec
40
- git clone [email protected] :epics-containers/.devcontainer.git
49
+ git clone < repo>
50
+ cd < repo>
41
51
code .
42
52
43
- This will open the workspace folder in Visual Studio Code. You will be prompted
53
+ This will open the project folder in Visual Studio Code. You will be prompted
44
54
to reopen the folder in a container. Click on the ``Reopen in Container `` button.
45
55
46
56
.. figure :: ../images/vscode-reopen-in-container.png
@@ -49,116 +59,13 @@ to reopen the folder in a container. Click on the ``Reopen in Container`` button
49
59
50
60
reopen in container dialogue
51
61
52
- Now all of your VSCode terminals and file explorer will be running inside of
53
- the devcontainer and have access to all the tools installed there.
54
-
55
- To verify things are working as expected, open a terminal in VSCode from
56
- the menus ``Terminal > New Terminal ``. You should see a prompt like this:
57
-
58
- .. code-block :: bash
59
-
60
- [E7][work-ec]$
61
-
62
- The E7 is used to indicate that you are running inside the
63
- ``dev-e7 `` developer container.
64
- ``work-ec `` is the name of the current working directory. You are
65
- welcome to alter the prompt by changing PS1 in ``.bashrc_dev `` (see next
66
- section), but it is a good idea to keep an indication of the container
67
- name in the prompt.
68
-
69
- Things to note:
70
-
71
- - Your workspace folder is mounted inside the container at the same path as
72
- the host folder it is mapped to. This means that you can edit files in
73
- the container and the changes are reflected outside the container and
74
- vice versa.
75
-
76
- - Your home folder is also mounted in its usual location. BUT $HOME is set
77
- to ``/root ``.
78
-
79
- - Podman users are running as root inside the container but files will be
80
- written with your user id and group id when writing to the mounted
81
- workspace folder (or your home directory).
82
-
83
- .. _devcontainer-configure :
84
-
85
- Configuring the Devcontainer
86
- ----------------------------
87
-
88
- .. note ::
89
-
90
- **DLS users **: the settings in the default ``.bashrc_dev `` are already
91
- configured for interacting with the test beamline bl01t on the test
92
- cluster Pollux. HOWEVER: for this exercise we will use your personal
93
- GitHub account to avoid clashes with other users of this tutorial.
94
- Therefore follow the instructions below and set KUBECONFIG as follows:
95
-
96
- .. code-block :: bash
97
-
98
- # point at your cluster configuration file
99
- export KUBECONFIG=/home/${USER} /.kube/config_pollux
100
-
101
- To enable access to the pollux cluster, execute the following commands
102
- from OUTSIDE of the dev container:
103
-
104
- .. code-block :: bash
105
-
106
- module load pollux
107
- klogout
108
- .devcontainer/dls-copy-k8s-crt.sh # a script in the .devcontainer repo
109
- kubectl get nodes
110
-
111
- The last command will ask for your fed-id and password and then show a
112
- list of nodes in the pollux cluster. Your credentials are cached for a
113
- week after which you will see authentication errors. To fix this
114
- repeat the above steps.
115
-
116
- You devcontainer environment is configured by a file called
117
- ``.bashrc_dev `` file. The terminals in the devcontainer will source this
118
- file when they start.
119
-
120
- Much of this file is setting up convenience features like the prompt and bash
121
- history. You can change these to suit your own preferences.
122
-
123
- The primary configuration options are the environment variables exported by
124
- this script. These are listed below with some recommended values for running
125
- these tutorials. Paste the following into the ``.bashrc_dev `` file and
126
- add your GitHub organization or user to K8S_HELM_REGISTRY.
127
-
128
- .. code-block :: bash
129
-
130
- # ########### REPLACE all environment below with your details ###################
62
+ You can also access the command via the CTRL+SHIFT+P menu:
131
63
132
- # point at your cluster config file
133
- export KUBECONFIG=/home/${USER} /.kube/config
134
-
135
- # the default domain for ec commands (REMOVE if this is supplied by the host)
136
- export K8S_DOMAIN=bl01t
137
-
138
- # where to get HELM charts for ec commands
139
- export K8S_HELM_REGISTRY=ghcr.io/< YOUR GITHUB USER OR ORGANIZATION>
140
-
141
- # ###############################################################################
142
-
143
- After editing ``.bashrc_dev `` you will need to close any open terminals and
144
- restart them to pick up the changes.
145
-
146
-
147
- .. Note ::
148
-
149
- For advanced users with knowledge of docker or podman.
150
-
151
- You can also alter the parameters for launch of the container by editing the
152
- ``.devcontainer/devcontainer.json `` file.
153
- `See here for details <https://containers.dev/implementors/json_reference/ >`_
154
-
155
- In addition, you can alter the system packages installed in the container or make
156
- any other changes to the Dockerfile and regenerate your own container image.
157
-
158
- To pick up such changes to ``.devcontainer `` run the ``Rebuild Container ``
159
- command from VSCode command pallette (accessed via ctrl-shift-P).
64
+ .. figure :: ../images/dev-container.png
65
+ :width: 600px
66
+ :align: center
160
67
161
- If you wish to persist these changes
162
- then it is suggested that you make your own github repo of .devcontainer and
163
- push the changes there.
68
+ devcontainer launch option
164
69
70
+ Now all of your VSCode terminals and file explorer will be running inside of
71
+ the devcontainer and have access to all the tools installed there.
0 commit comments