Skip to content

Commit cabe6e3

Browse files
authored
Don't run as root in containers (#218)
* Don't use root in our containers * move some more libs into base image * remove collector-fluentd * add more resources for building the base image
1 parent e380a91 commit cabe6e3

29 files changed

Lines changed: 36 additions & 727 deletions

File tree

docs/dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pipenv shell
2424
To build all images run:
2525

2626
``` bash
27-
infrabox run
27+
infrabox run ib
2828
./ib.py images build
2929
```
3030

ib.py

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import logging
77
import sys
88

9-
from Crypto.PublicKey import RSA
10-
119
logging.basicConfig(
1210
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
1311
datefmt='%d-%m-%Y:%H:%M:%S',
@@ -23,11 +21,10 @@
2321
{'name': 'github-trigger', 'depends_on': ['images-base']},
2422
{'name': 'github-review', 'depends_on': ['images-base']},
2523
{'name': 'collector-api'},
26-
{'name': 'collector-fluentd'},
2724
{'name': 'job'},
2825
{'name': 'opa'},
2926
{'name': 'gc', 'depends_on': ['images-base']},
30-
{'name': 'scheduler-kubernetes'},
27+
{'name': 'scheduler-kubernetes', 'depends_on': ['images-base']},
3128
{'name': 'api', 'depends_on': ['images-base']},
3229
{'name': 'build-dashboard-client'},
3330
{'name': 'static', 'depends_on': ['build-dashboard-client']},
@@ -126,32 +123,6 @@ def images_push(args):
126123
print('invalid type')
127124
sys.exit(1)
128125

129-
def _setup_rsa_keys():
130-
private_key_path = '/tmp/ib/run/rsa/id_rsa'
131-
public_key_path = '/tmp/ib/run/rsa/id_rsa.pub'
132-
133-
key = RSA.generate(2048)
134-
135-
if not os.path.exists(private_key_path):
136-
logger.warn('Private key does not exist: %s', private_key_path)
137-
logger.warn('Recreating it')
138-
139-
if not os.path.exists(os.path.dirname(private_key_path)):
140-
os.makedirs(os.path.dirname(private_key_path))
141-
142-
with open(private_key_path, 'w+') as s:
143-
s.write(str(key.exportKey()))
144-
145-
if not os.path.exists(public_key_path):
146-
logger.warn('Public key does not exist: %s', public_key_path)
147-
logger.warn('Recreating it')
148-
149-
if not os.path.exists(os.path.dirname(public_key_path)):
150-
os.makedirs(os.path.dirname(public_key_path))
151-
152-
with open(public_key_path, 'w+') as s:
153-
s.write(str(key.publickey().exportKey()))
154-
155126
def services_start(args):
156127
if args.service_name == 'storage':
157128
execute(['docker-compose', 'up'],
@@ -222,15 +193,15 @@ def main():
222193

223194
images_build_parser = sub_images.add_parser('build')
224195
images_build_parser.set_defaults(func=images_build)
225-
images_build_parser.add_argument("--registry", default='localhost:5000')
196+
images_build_parser.add_argument("--registry", default='quay.io')
226197
images_build_parser.add_argument("--tag", default='latest')
227198
images_build_parser.add_argument("--filter", default='.*')
228199
images_build_parser.add_argument("--push", action='store_true', default=False)
229200
images_build_parser.add_argument("--type", default='registry')
230201

231202
images_push_parser = sub_images.add_parser('push')
232203
images_push_parser.set_defaults(func=images_push)
233-
images_push_parser.add_argument("--registry", default='localhost:5000')
204+
images_push_parser.add_argument("--registry", default='quay.io')
234205
images_push_parser.add_argument("--tag", default='latest')
235206
images_push_parser.add_argument("--filter", default='.*')
236207
images_push_parser.add_argument("--type", default='registry')

infrabox/deploy/static/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.13.6
1+
FROM nginx:1.15-alpine
22

33
COPY src/landing /usr/share/nginx/html
44
COPY .infrabox/inputs/build-dashboard-client/dist /usr/share/nginx/html/dashboard

infrabox/generator/deployments.json

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -163,33 +163,6 @@
163163
"image": true
164164
}
165165
},
166-
{
167-
"type": "docker",
168-
"build_context": "../..",
169-
"name": "collector-fluentd",
170-
"docker_file": "src/collector-fluentd/Dockerfile",
171-
"build_only": true,
172-
"resources": {
173-
"limits": {
174-
"cpu": 1,
175-
"memory": 1024
176-
}
177-
},
178-
"deployments": [
179-
{
180-
"type": "docker-registry",
181-
"host": "quay.io/infrabox",
182-
"repository": "collector-fluentd",
183-
"username": "infrabox+infrabox_ci",
184-
"password": {
185-
"$secret": "QUAY_PASSWORD"
186-
}
187-
}
188-
],
189-
"cache": {
190-
"image": true
191-
}
192-
},
193166
{
194167
"type": "docker",
195168
"build_context": "../..",

infrabox/generator/images.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"resources": {
1010
"limits": {
1111
"cpu": 1,
12-
"memory": 1024
12+
"memory": 2048
1313
}
1414
},
1515
"deployments": [

infrabox/test/pyinfraboxutils/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM quay.io/infrabox/images-test:build_$INFRABOX_BUILD_NUMBER
33

44
ENV PYTHONPATH=/infrabox/context/src
55

6-
COPY infrabox/test/pyinfraboxutils /test
6+
COPY --chown=infrabox infrabox/test/pyinfraboxutils /test
77
WORKDIR test
88

99
CMD /infrabox/context/infrabox/test/utils/python_tests.sh /infrabox/context/src/pyinfraboxutils '*'
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
coverage run --source=.,$1 --branch test.py
44

5-
rc=$?
6-
7-
echo "exit code $rc"
8-
95
set -e
106

117
coverage report -m
@@ -16,14 +12,3 @@ if [ -e results.xml ]; then
1612
fi
1713

1814
cp coverage.xml /infrabox/upload/coverage
19-
20-
21-
#if [[ ! -z "$CODECOV_TOKEN" ]]; then
22-
# if [[ -z "$INFRABOX_GIT_BRANCH" ]]; then
23-
# codecov -t $CODECOV_TOKEN --root /infrabox/context -f coverage.xml
24-
# else
25-
# codecov -t $CODECOV_TOKEN --root /infrabox/context -f coverage.xml -b $INFRABOX_GIT_BRANCH
26-
# fi
27-
#fi
28-
29-
exit $rc

src/collector-fluentd/Dockerfile

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/collector-fluentd/Gemfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/collector-fluentd/Gemfile.lock

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)