This repository has been archived by the owner on Aug 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #795 from open-craft/joaocabrita/ocim_in_docker
feature: Added ability to run OCIM in a container.
- Loading branch information
Showing
11 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
frontend/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM python:3.6 | ||
|
||
WORKDIR /usr/src/ocim | ||
|
||
COPY requirements.txt ./ | ||
COPY requirements/ requirements/ | ||
RUN pip install -r requirements.txt | ||
|
||
COPY Makefile \ | ||
package.json \ | ||
./ | ||
COPY frontend/ frontend/ | ||
COPY static/ static/ | ||
|
||
CMD ["make", "run.dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Docker Compose file for the services needed by Ocim, for easy local development setup | ||
|
||
version: "3.6" | ||
|
||
services: | ||
|
||
postgresql: | ||
image: postgres:12.6-alpine | ||
environment: | ||
POSTGRES_USER: opencraft | ||
POSTGRES_DB: opencraft | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
POSTGRES_INITDB_ARGS: --encoding utf-8 | ||
volumes: | ||
- /var/lib/postgresql/data | ||
ports: | ||
- "5432:5432" | ||
|
||
redis: | ||
image: postgres:12.6-alpine | ||
image: redis:4 | ||
ports: | ||
- "6379:6379" | ||
|
||
ocim: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.ocim | ||
depends_on: | ||
- postgresql | ||
- redis | ||
env_file: .env | ||
environment: | ||
ALLOWED_HOSTS: '["*"]' | ||
DATABASE_URL: '${DATABASE_URL:-postgres://opencraft@postgresql/opencraft}' | ||
REDIS_URL: '${REDIS_URL:-redis://redis:6379}' | ||
ports: | ||
- "127.0.0.1:5000:5000" | ||
volumes: | ||
- ./:/usr/src/ocim/ | ||
|
||
ocim-frontend: | ||
build: | ||
context: frontend/ | ||
depends_on: | ||
- ocim | ||
environment: {} | ||
ports: | ||
- "127.0.0.1:3000:3000" | ||
tty: true | ||
volumes: | ||
- ./frontend:/usr/src/ocim-frontend/ | ||
- ./static:/usr/src/static | ||
|
||
volumes: {} | ||
|
||
networks: | ||
default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Docker | ||
|
||
This describes how to create an environment for development using Docker. | ||
|
||
**This is still experimental, using [Vagrant](../installation.md) is much better tested and supported!** | ||
|
||
## Running OCIM in a docker container | ||
|
||
First, set your `.env` file as you would normally: | ||
```env | ||
DEBUG=True | ||
OPENSTACK_USER='username' | ||
OPENSTACK_PASSWORD='password' | ||
OPENSTACK_TENANT='tenant-name' | ||
OPENSTACK_AUTH_URL='https://auth.cloud.ovh.net/v2.0' | ||
OPENSTACK_REGION='BHS1' | ||
OPENSTACK_SANDBOX_SSH_KEYNAME='keypair-name' | ||
DEFAULT_INSTANCE_BASE_DOMAIN='example.com' | ||
GANDI_API_KEY='api-key' | ||
GITHUB_ACCESS_TOKEN='github-token' | ||
SECRET_KEY='tests' | ||
DEFAULT_INSTANCE_MYSQL_URL=... | ||
DEFAULT_RABBITMQ_API_URL=... | ||
DEFAULT_INSTANCE_RABBITMQ_URL=... | ||
DEFAULT_MONGO_REPLICA_SET_USER=... | ||
DEFAULT_MONGO_REPLICA_SET_PASSWORD=... | ||
DEFAULT_MONGO_REPLICA_SET_NAME=... | ||
DEFAULT_MONGO_REPLICA_SET_PRIMARY=... | ||
DEFAULT_MONGO_REPLICA_SET_HOSTS=... | ||
REDIS_URL=... | ||
``` | ||
|
||
Start a one-off container for setup of the backend: | ||
```sh | ||
# --rm destroys the container at the end | ||
docker-compose run --rm ocim bash | ||
|
||
# then, inside the container... | ||
|
||
# initialize datastores | ||
make migrate | ||
# create super user | ||
make manage createsuperuser | ||
# exit the container | ||
exit | ||
``` | ||
|
||
Then, start another one-off container for setting up the client-facing frontend: | ||
```sh | ||
docker-compose run --rm ocim-frontend bash -c 'npm run build-api-client && npm install' | ||
``` | ||
|
||
Then, start OCIM: | ||
```sh | ||
docker-compose up | ||
``` | ||
|
||
The OCIM UI should be available at http://localhost:5000 . | ||
The registration UI should be available at http://localhost:3000 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:11.15.0 | ||
|
||
# https://github.com/Automattic/node-canvas#compiling | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
libcairo2-dev \ | ||
libpango1.0-dev \ | ||
libjpeg-dev \ | ||
libgif-dev \ | ||
librsvg2-dev | ||
|
||
WORKDIR /usr/src/ocim-frontend | ||
COPY ./ /usr/src/ocim-frontend | ||
|
||
# Move node_modules out of the source path | ||
RUN npm install -g --unsafe-perm | ||
|
||
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ nav: | |
- howtos.md | ||
- periodic_builds.md | ||
- infrastructure.md | ||
- "Development": | ||
- "Docker": development/docker.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters