Skip to content

Commit f7d59d5

Browse files
committed
Initial commit
0 parents  commit f7d59d5

File tree

6 files changed

+119
-0
lines changed

6 files changed

+119
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Inetum Orléans
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# djp-template
2+
3+
A [ddb](https://inetum-orleans.github.io/docker-devbox-ddb) jsonnet package (**djp**).
4+
5+
## Description
6+
7+
[NodeJS](https://nodejs.org/) **djp** package.
8+
9+
## Snippet
10+
11+
- `ddb.yml`
12+
13+
```yaml
14+
cookiecutter:
15+
templates:
16+
- template: gh:inetum-orleans/djp-node
17+
extra_context:
18+
node_version: "14"
19+
```
20+
21+
- `docker-compose.yml.jsonnet`
22+
23+
```jsonnet
24+
ddb.Compose(
25+
ddb.with(
26+
import '.docker/node/djp.libjsonnet'
27+
)
28+
)
29+
```
30+
31+
## Parameters
32+
33+
| name | type | description |
34+
| ------------- | ------------- | ------------- |
35+
36+
## Usage
37+
38+
Please check [jsonnet feature](https://inetum-orleans.github.io/docker-devbox-ddb/features/jsonnet/#ddb-jsonnet-packages-djp)
39+
to understand how to include a **djp** package inside a [ddb](https://inetum-orleans.github.io/docker-devbox-ddb) project.
40+
41+
Looking for other [djp packages](https://github.com/inetum-orleans?q=djp-) ? Check github repositories starting with `djp-`.

cookiecutter.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"directory": ".docker/node",
3+
"node_version": "14"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:{{ cookiecutter.node_version }}
2+
3+
RUN mkdir -p /project
4+
WORKDIR /project
5+
6+
USER node
7+
8+
RUN npm config set prefix /home/node/.npm-packages
9+
ENV PATH="${PATH}:/home/node/.npm-packages/bin"
10+
11+
VOLUME /project
12+
VOLUME /home/node/.cache
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
local ddb = import 'ddb.docker.libjsonnet';
2+
3+
local defaultName = ddb.File(std.thisFile).parent.name;
4+
5+
// Docker compose configuration factory for this package.
6+
local factory(name, params={}) =
7+
// Sanitize and set params default values in o using ddb.params.value and ddb.params.array.
8+
local o = {
9+
// param1: ddb.params.value(params, 'param1', 'default1'),
10+
// param2: ddb.params.array(params, 'param2', ['default2']),
11+
};
12+
13+
// Return a docker compose configuration that should configure this package inside a global configuration.
14+
{services+: {
15+
[name]+:
16+
ddb.Build(defaultName) +
17+
ddb.User() +
18+
ddb.Binary("node", "/project", "node", exe=true) +
19+
ddb.Binary("npm", "/project", "npm", exe=true) +
20+
ddb.Binary("npx", "/project", "npx", exe=true) +
21+
{
22+
tty: true,
23+
volumes+: [
24+
ddb.path.project + ":/project",
25+
name + "-cache:/home/node/.cache",
26+
name + "-npm-packages:/home/node/.npm-packages"
27+
]
28+
}
29+
}
30+
};
31+
32+
{
33+
factory: factory,
34+
defaultName: defaultName
35+
}

{{cookiecutter.directory}}/fixuid.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
user: node
2+
group: node
3+
paths:
4+
- /
5+
- /home/node/.cache
6+
- /home/node/.npm-packages

0 commit comments

Comments
 (0)