-
Notifications
You must be signed in to change notification settings - Fork 19
65 - Containerized development environment #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
836b437
5ccd29b
17fa910
0d62e3f
9a9dc7a
fb80ebf
12b80e4
eaf2651
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| POSTGRES_VERSION=13 | ||
| DATAVERSE_DB_USER=dataverse | ||
| SOLR_VERSION=8.11.1 | ||
| REGISTRY=ghcr.io |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| version: '2.4' | ||
|
|
||
| services: | ||
| dev_nginx: | ||
| container_name: 'dev_nginx_proxy' | ||
| image: nginx:stable | ||
| ports: | ||
| - '8000:80' | ||
| networks: | ||
| - dataverse | ||
| depends_on: | ||
| - dev_dataverse | ||
| - dev_frontend | ||
| volumes: | ||
| - ./nginx.conf:/etc/nginx/nginx.conf | ||
| - ./docker-dev-volumes/nginx/logs:/var/log/nginx/ | ||
|
|
||
| dev_frontend: | ||
| container_name: 'dev_frontend' | ||
| hostname: frontend | ||
| build: | ||
| context: ../ | ||
| dockerfile: ./dev.Dockerfile | ||
| network: host | ||
| expose: | ||
| - '5173' | ||
| stdin_open: true | ||
| networks: | ||
| - dataverse | ||
| depends_on: | ||
| - dev_dataverse | ||
| environment: | ||
| - VITE_DATAVERSE_BACKEND_URL=http://localhost:8000 | ||
| volumes: | ||
| - ../:/usr/src/app | ||
| - /usr/src/app/dev-env | ||
| - /usr/src/app/node_modules | ||
|
|
||
| dev_dataverse: | ||
| container_name: 'dev_dataverse' | ||
| hostname: dataverse | ||
| image: ${REGISTRY}/gdcc/dataverse:${DATAVERSE_BRANCH_NAME} | ||
| restart: on-failure | ||
| user: payara | ||
| environment: | ||
| - DATAVERSE_DB_HOST=postgres | ||
| - DATAVERSE_DB_PASSWORD=secret | ||
| - DATAVERSE_DB_USER=${DATAVERSE_DB_USER} | ||
| - DATAVERSE_FEATURE_API_SESSION_AUTH=1 | ||
| # We open 8080, rather than just expose, so that the docker-final-setup.sh script works from the run-env.sh script | ||
| ports: | ||
| - '8080:8080' | ||
| networks: | ||
| - dataverse | ||
| depends_on: | ||
| - dev_postgres | ||
| - dev_solr | ||
| volumes: | ||
| - ./docker-dev-volumes/app/data:/dv | ||
| - ./docker-dev-volumes/app/secrets:/secrets | ||
| tmpfs: | ||
| - /dumps:mode=770,size=2052M,uid=1000,gid=1000 | ||
| - /tmp:mode=770,size=2052M,uid=1000,gid=1000 | ||
| mem_limit: 2147483648 # 2 GiB | ||
| mem_reservation: 1024m | ||
| privileged: false | ||
|
|
||
| dev_postgres: | ||
| container_name: 'dev_postgres' | ||
| hostname: postgres | ||
| image: postgres:${POSTGRES_VERSION} | ||
| restart: on-failure | ||
| environment: | ||
| - POSTGRES_USER=${DATAVERSE_DB_USER} | ||
| - POSTGRES_PASSWORD=secret | ||
| ports: | ||
| - '5432:5432' | ||
| networks: | ||
| - dataverse | ||
| volumes: | ||
| - ./docker-dev-volumes/postgresql/data:/var/lib/postgresql/data | ||
|
|
||
| dev_solr_initializer: | ||
| container_name: 'dev_solr_initializer' | ||
| image: alpine | ||
| restart: 'no' | ||
| command: | ||
| - sh | ||
| - -c | ||
| - 'chown 8983:8983 /conf /var/solr && cp *.xml /conf' | ||
| volumes: | ||
| - ./docker-dev-volumes/solr/data:/var/solr | ||
| - ./docker-dev-volumes/solr/conf:/conf | ||
| - ./dataverse/conf/solr/8.11.1/schema.xml:/schema.xml | ||
| - ./dataverse/conf/solr/8.11.1/solrconfig.xml:/solrconfig.xml | ||
|
|
||
| dev_solr: | ||
| container_name: 'dev_solr' | ||
| hostname: 'solr' | ||
| image: solr:${SOLR_VERSION} | ||
| depends_on: | ||
| - dev_solr_initializer | ||
| restart: on-failure | ||
| expose: | ||
| - '8983' | ||
| networks: | ||
| - dataverse | ||
| command: | ||
| - bash | ||
| - -c | ||
| - 'cd /opt/solr-${SOLR_VERSION}/server/solr/configsets/_default/conf && cp -R -n . /template && solr-precreate collection1 /template' | ||
| volumes: | ||
| - ./docker-dev-volumes/solr/data:/var/solr | ||
| - ./docker-dev-volumes/solr/conf:/template | ||
|
|
||
| dev_smtp: | ||
| container_name: 'dev_smtp' | ||
| hostname: 'smtp' | ||
| image: maildev/maildev:2.0.5 | ||
| restart: on-failure | ||
| expose: | ||
| - '25' # smtp server | ||
| ports: | ||
| - '1080:1080' # web ui | ||
| environment: | ||
| - MAILDEV_SMTP_PORT=25 | ||
| - MAILDEV_MAIL_DIRECTORY=/mail | ||
| networks: | ||
| - dataverse | ||
| #volumes: | ||
| # - ./docker-dev-volumes/smtp/data:/mail | ||
| tmpfs: | ||
| - /mail:mode=770,size=128M,uid=1000,gid=1000 | ||
|
|
||
| networks: | ||
| dataverse: | ||
| driver: bridge |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| base_url = 'http://localhost:8000' | ||
| api_token = '<DATAVERSE_API_TOKEN>' | ||
| sample_data = [ | ||
| 'data/dataverses/pums/pums.json', | ||
| 'data/dataverses/pums/datasets/2000pums5/2000pums5.json', | ||
| 'data/dataverses/dataverseno/dataverseno.json', | ||
| 'data/dataverses/open-source-at-harvard/open-source-at-harvard.json', | ||
| 'data/dataverses/open-source-at-harvard/dataverses/dataverse-project/dataverse-project.json', | ||
| 'data/dataverses/open-source-at-harvard/dataverses/dataverse-project/datasets/dataverse-irc-metrics/dataverse-irc-metrics.json', | ||
| 'data/dataverses/ubiquity-press/ubiquity-press.json', | ||
| 'data/dataverses/ubiquity-press/dataverses/jopd/jopd.json', | ||
| 'data/dataverses/ubiquity-press/dataverses/jopd/datasets/flynn-effect-in-estonia/flynn-effect-in-estonia.json', | ||
| 'data/dataverses/ubiquity-press/dataverses/jopd/datasets/bafacalo/bafacalo.json', | ||
| 'data/dataverses/king/king.json', | ||
| 'data/dataverses/king/datasets/cause-of-death/cause-of-death.json', | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| events {} | ||
| http { | ||
| server { | ||
| listen 80; | ||
| server_name localhost; | ||
|
|
||
| location / { | ||
| proxy_pass http://dataverse:8080; | ||
| } | ||
|
|
||
| location /spa { | ||
| proxy_pass http://frontend:5173; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection "Upgrade"; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| docker-compose -f "./docker-compose-dev.yml" down | ||
| rm -rf ./docker-dev-volumes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| export DATAVERSE_BRANCH_NAME=$1 | ||
|
|
||
| # To avoid timeout issues on frontend container startup | ||
| export COMPOSE_HTTP_TIMEOUT=200 | ||
|
|
||
| DATAVERSE_API_BASE_URL=http://localhost:8000/api | ||
|
|
||
| echo "INFO - Setting up Dataverse on branch ${DATAVERSE_BRANCH_NAME}..." | ||
|
|
||
| echo "INFO - Removing current environment if exists..." | ||
| ./rm-env.sh | ||
|
|
||
| echo "INFO - Cloning Dataverse backend repository..." | ||
| git clone -b ${DATAVERSE_BRANCH_NAME} git@github.com:IQSS/dataverse.git | ||
|
|
||
| echo "INFO - Running docker containers..." | ||
| docker-compose -f "./docker-compose-dev.yml" up -d --build | ||
|
|
||
| echo "INFO - Waiting for containers to be ready..." | ||
|
Comment on lines
+18
to
+21
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, I had an existing containerized dev env so I'm getting these errors:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried this:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that didn't help. I think I need to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running |
||
| # Up to ~5 minutes | ||
| max_attempts=30 | ||
| n_attempts=0 | ||
| until $(curl --output /dev/null --silent --head --fail ${DATAVERSE_API_BASE_URL}/info/version); do | ||
| if [ ${n_attempts} -eq ${max_attempts} ];then | ||
| echo "ERROR - Timeout reached while waiting for containers to be ready" | ||
| ./rm-env.sh | ||
| rm -rf dataverse | ||
| exit 1 | ||
| fi | ||
| n_attempts=$(($n_attempts+1)) | ||
| sleep 10 | ||
| done | ||
|
|
||
| echo "INFO - Bootstrapping dataverse..." | ||
| cd dataverse | ||
| ./scripts/dev/docker-final-setup.sh | ||
|
|
||
| echo "INFO - Cleaning up repository..." | ||
| cd .. | ||
| rm -rf dataverse | ||
|
|
||
| echo "INFO - Cloning Dataverse sample data repository..." | ||
| git clone git@github.com:IQSS/dataverse-sample-data.git | ||
|
|
||
| echo "INFO - Configuring Dataverse sample data repository..." | ||
| cd dataverse-sample-data | ||
| python3 -m venv venv | ||
| source venv/bin/activate | ||
| pip install -r requirements.txt | ||
| cp ../dvconfig.py ./dvconfig.py | ||
| curl -X PUT -d 'true' ${DATAVERSE_API_BASE_URL}/admin/settings/:AllowApiTokenLookupViaApi | ||
| dataverse_api_token=$(python3 get_api_token.py) | ||
| sed -i '' "s/<DATAVERSE_API_TOKEN>/${dataverse_api_token}/g" dvconfig.py | ||
|
|
||
| echo "INFO - Creating sample data..." | ||
| python3 create_sample_data.py | ||
|
Comment on lines
+57
to
+58
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some sample data was created (screenshot below, honestly this is probably enough) but then the script exited early with this error:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's line 76, uploading a file: |
||
|
|
||
| echo "INFO - Cleaning up repository..." | ||
| cd .. | ||
| rm -rf dataverse-sample-data | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FROM node:19.6.1 | ||
| WORKDIR /usr/src/app | ||
| COPY package.json ./ | ||
| RUN npm install | ||
| EXPOSE 5173 | ||
| CMD ["npm", "start"] |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to note that the autoupdating is working great!
I added "FOOBAR" to the Hello Dataverse page and as soon as I saved the file the text appeared, like this:
Here was the change: