Skip to content

Commit b89d167

Browse files
Jeny Sadadianuclearcat
Jeny Sadadia
authored andcommitted
Add docker-compose file for developer mode
Enable developer to use local volume binds by adding `dev-docker-compose.yaml` file. Also add `Dockerfile` to provide ability to build `api` container locally. This file is intended for developer use only. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
1 parent ec42a9b commit b89d167

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

dev-docker-compose.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# Copyright (C) 2024 Collabora Limited
4+
# Author: Jeny Sadadia <jeny.sadadia@collabora.com>
5+
6+
version: '3'
7+
services:
8+
9+
api:
10+
container_name: 'kernelci-api'
11+
build:
12+
context: 'docker/api'
13+
args:
14+
- REQUIREMENTS=${REQUIREMENTS:-requirements.txt}
15+
- core_rev=${CORE_REV:-main}
16+
volumes:
17+
- './api:/home/kernelci/api'
18+
- './tests:/home/kernelci/tests'
19+
- './migrations:/home/kernelci/migrations'
20+
- './templates:/home/kernelci/templates'
21+
ports:
22+
- '${API_HOST_PORT:-8001}:8000'
23+
env_file:
24+
- '.env'
25+
26+
db:
27+
container_name: 'kernelci-api-db'
28+
image: 'mongo:5.0'
29+
command: '--wiredTigerCacheSizeGB=0.5'
30+
ports:
31+
- '${MONGO_HOST_PORT:-8017}:27017'
32+
volumes:
33+
- 'mongodata:/data/db'
34+
35+
redis:
36+
container_name: 'kernelci-api-redis'
37+
image: 'redis:6.2'
38+
volumes:
39+
- './docker/redis/data:/data'
40+
41+
storage:
42+
container_name: 'kernelci-api-storage'
43+
image: 'nginx:1.21.3'
44+
volumes:
45+
- './docker/storage/data:/usr/share/nginx/html'
46+
- './docker/storage/config/default.conf:/etc/nginx/conf.d/default.conf'
47+
ports:
48+
- ${STORAGE_HOST_PORT:-8002}:80
49+
50+
ssh:
51+
container_name: 'kernelci-api-ssh'
52+
build:
53+
context: 'docker/ssh'
54+
volumes:
55+
- './docker/storage/data:/home/kernelci/data'
56+
- './docker/ssh/user-data:/home/kernelci/.ssh'
57+
ports:
58+
- '${SSH_HOST_PORT:-8022}:22'
59+
60+
volumes:
61+
mongodata:

docker/api/Dockerfile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# Copyright (C) 2021 Collabora Limited
4+
# Author: Guillaume Tucker <guillaume.tucker@collabora.com>
5+
6+
FROM python:3.10
7+
MAINTAINER "KernelCI TSC" <kernelci-tsc@groups.io>
8+
9+
RUN apt-get update && apt-get install --no-install-recommends -y git
10+
11+
# Upgrade pip3 - never mind the warning about running this as root
12+
RUN pip3 install --upgrade pip
13+
14+
# Create kernelci user
15+
RUN useradd kernelci -u 1000 -d /home/kernelci -s /bin/bash
16+
RUN mkdir -p /home/kernelci
17+
RUN chown kernelci: /home/kernelci
18+
USER kernelci
19+
ENV PATH=$PATH:/home/kernelci/.local/bin
20+
WORKDIR /home/kernelci
21+
22+
# Install requirements
23+
COPY requirements*.txt /home/kernelci/
24+
ARG REQUIREMENTS=requirements.txt
25+
RUN pip install --requirement ${REQUIREMENTS}
26+
27+
# Install kernelci Python package from kernelci-core
28+
USER root
29+
ARG core_url=https://github.com/kernelci/kernelci-core.git
30+
ARG core_rev=main
31+
RUN git clone --depth=1 $core_url /tmp/kernelci-core
32+
WORKDIR /tmp/kernelci-core
33+
RUN git fetch origin $core_rev
34+
RUN git checkout FETCH_HEAD
35+
RUN python3 -m pip install .
36+
RUN cp -R config /etc/kernelci/
37+
WORKDIR /home/kernelci
38+
RUN rm -rf /tmp/kernelci-core
39+
USER kernelci
40+
41+
CMD ["uvicorn", "api.main:versioned_app", "--host", "0.0.0.0", "--reload"]

0 commit comments

Comments
 (0)