diff --git a/Makefile b/Makefile new file mode 100644 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +ALL_DOCKERFILES := $(wildcard dockerfiles/Dockerfile-*) +ALL_BUILD_TARGETS := $(subst dockerfiles/Dockerfile-,build-,$(ALL_DOCKERFILES)) + +all: $(ALL_BUILD_TARGETS) + +run: $(ALL_BUILD_TARGETS) + # Discard existing volumes + docker-compose down --volumes + # Runs containers in the foreground + docker-compose up + +build-%: dockerfiles/Dockerfile-% + @echo "" + @echo "+----------------------------------------------------+" + @printf '| %-50s |\n' "Building $(subst build-,,$@)" + @echo "+----------------------------------------------------+" + @echo "" + docker build -f $< -t $(subst build-,,$@) $(BUILD_CONTEXT) .. diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -3,3 +3,13 @@ [Work in progress] This repo contains Dockerfiles to allow developers to run a small Software Heritage instance on their development computer. + +## How to use + +``` +make run +``` + +This will build docker images and run them using docker-compose. + +Press Ctrl-C when you want to stop it. diff --git a/config/objstorage/server.yml b/config/objstorage/server.yml new file mode 100644 --- /dev/null +++ b/config/objstorage/server.yml @@ -0,0 +1,5 @@ +objstorage: + cls: pathslicing + args: + root: /srv/softwareheritage/objects + slicing: 0:2/2:4/4:6 diff --git a/config/storage/storage.yml b/config/storage/storage.yml new file mode 100644 --- /dev/null +++ b/config/storage/storage.yml @@ -0,0 +1,8 @@ +storage: + cls: local + args: + db: "host=pgsql-storage port=5432 user=postgres password=testpassword" # FIXME: this should not be hardcoded + objstorage: + cls: remote + args: + url: http://swh-objstorage:5003/ # FIXME: this should not be hardcoded diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '2.0' + +services: + + pgsql-storage: + image: swh-storage-pg + restart: always + environment: + POSTGRES_PASSWORD: testpassword + + swh-storage: + image: swh-storage + restart: always + ports: + - 5002:5002 + + swh-objstorage: + image: swh-objstorage + restart: always + ports: + - 5003:5003 diff --git a/dockerfiles/Dockerfile-swh-objstorage b/dockerfiles/Dockerfile-swh-objstorage new file mode 100644 --- /dev/null +++ b/dockerfiles/Dockerfile-swh-objstorage @@ -0,0 +1,20 @@ +FROM python:3 + +RUN apt-get update +RUN apt-get install -y libsystemd-dev + +RUN mkdir -p /srv/softwareheritage/objects + +WORKDIR /usr/local/src/ +COPY ./swh-objstorage/requirements*.txt ./swh-objstorage/ + +RUN pip install -r ./swh-objstorage/requirements.txt -r ./swh-objstorage/requirements-swh.txt + +COPY ./swh-docker-dev/config/ /etc/softwareheritage/ + +COPY . . +RUN pip install -e ./swh-objstorage/ + +ENTRYPOINT ["python", "-m", "swh.objstorage.api.server", "/etc/softwareheritage/objstorage/server.yml"] + +EXPOSE 5003 diff --git a/dockerfiles/Dockerfile-swh-storage b/dockerfiles/Dockerfile-swh-storage new file mode 100644 --- /dev/null +++ b/dockerfiles/Dockerfile-swh-storage @@ -0,0 +1,21 @@ +FROM python:3 + +RUN apt-get update +RUN apt-get install -y libsystemd-dev + +WORKDIR /usr/local/src/ +COPY ./swh-storage/requirements*.txt ./swh-storage/ + +RUN pip install -r ./swh-storage/requirements.txt -r ./swh-storage/requirements-swh.txt + +COPY ./swh-docker-dev/config/ /etc/softwareheritage/ + +COPY . . +RUN pip install -e ./swh-storage/ + +RUN cat /etc/softwareheritage/storage/storage.yml + +ENTRYPOINT ["python", "-m", "swh.storage.api.server", "/etc/softwareheritage/storage/storage.yml"] + +EXPOSE 5002 + diff --git a/dockerfiles/Dockerfile-swh-storage-pg b/dockerfiles/Dockerfile-swh-storage-pg new file mode 100644 --- /dev/null +++ b/dockerfiles/Dockerfile-swh-storage-pg @@ -0,0 +1,3 @@ +FROM postgres + +COPY ./swh-storage/swh/storage/sql/ /docker-entrypoint-initdb.d