diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e246ef3 --- /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 index 415b859..6152ff5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # swh-docker-dev [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 index 0000000..ada29aa --- /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 index 0000000..9983f06 --- /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 index 0000000..90c12fb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '2.0' + +services: + + pgsql-storage: + image: swh-storage-pg + environment: + POSTGRES_PASSWORD: testpassword + + swh-storage: + image: swh-storage + ports: + - 5002:5002 + + swh-objstorage: + image: swh-objstorage + ports: + - 5003:5003 diff --git a/dockerfiles/Dockerfile-swh-objstorage b/dockerfiles/Dockerfile-swh-objstorage new file mode 100644 index 0000000..2f441b9 --- /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 index 0000000..a2251a9 --- /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 index 0000000..6c0c8a8 --- /dev/null +++ b/dockerfiles/Dockerfile-swh-storage-pg @@ -0,0 +1,4 @@ +FROM postgres + +# Create the swh-storage's database when the container starts. +COPY ./swh-storage/swh/storage/sql/ /docker-entrypoint-initdb.d