-
Notifications
You must be signed in to change notification settings - Fork 12
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
Streamline local dev process with hot reloading, Dockerfile.dev updates, and resolved fixtures #1809
Streamline local dev process with hot reloading, Dockerfile.dev updates, and resolved fixtures #1809
Changes from 2 commits
48dde05
ccfd739
14cb1a3
25e01d6
31789a5
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,31 @@ | ||||||||||||
#!/bin/bash | ||||||||||||
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.
? |
||||||||||||
|
||||||||||||
# This script can be used to launch both the frontend and backend with ease locally | ||||||||||||
# Happy developing! | ||||||||||||
|
||||||||||||
if [ $# -lt 2 ]; then | ||||||||||||
echo "Usage: $0 <image_name> <your.email@email.com>" | ||||||||||||
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. Please checkout #1828 . If agree -- may be
|
||||||||||||
exit 1 | ||||||||||||
fi | ||||||||||||
|
||||||||||||
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.
Suggested change
|
||||||||||||
image_name=$1 | ||||||||||||
email=$2 | ||||||||||||
|
||||||||||||
cd web/ | ||||||||||||
|
||||||||||||
# Build Docker image (include the path to the Dockerfile's context) | ||||||||||||
docker build -t $image_name -f Dockerfile.dev . | ||||||||||||
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.
Suggested change
run |
||||||||||||
|
||||||||||||
# Run the Docker container for frontend in background | ||||||||||||
docker run -d -v "$(pwd):/usr/src/app" -v /usr/src/app/node_modules -p 8085:8085 -e CHOKIDAR_USEPOLLING=true $image_name | ||||||||||||
|
||||||||||||
cd .. | ||||||||||||
|
||||||||||||
# Run Docker Compose commands for backend | ||||||||||||
docker-compose run --rm django ./manage.py migrate | ||||||||||||
docker-compose run --rm django ./manage.py createcachetable | ||||||||||||
docker-compose run --rm django ./manage.py createsuperuser | ||||||||||||
docker-compose run --rm django ./manage.py create_dev_dandiset --owner $email | ||||||||||||
|
||||||||||||
# Bring backend application to life! | ||||||||||||
docker-compose up |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import hashlib | ||
from uuid import uuid4 | ||
|
||
from django.conf import settings | ||
|
@@ -15,8 +16,14 @@ | |
@click.command() | ||
@click.option('--name', default='Development Dandiset') | ||
@click.option('--owner', 'email', required=True, help='The email address of the owner') | ||
def create_dev_dandiset(*, name: str, email: str): | ||
owner = User.objects.get(email=email) | ||
@click.option('--first_name', default='Randi The Admin') | ||
@click.option('--last_name', default='Dandi') | ||
def create_dev_dandiset(name: str, email: str, first_name: str, last_name: str): | ||
owner, is_created = User.objects.get_or_create(email=email) | ||
if not is_created: | ||
owner.first_name = first_name | ||
owner.last_name = last_name | ||
owner.save() | ||
Comment on lines
+19
to
+26
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. The intent of this script is for it to be run after |
||
|
||
version_metadata = { | ||
'description': 'An informative description', | ||
|
@@ -26,16 +33,19 @@ def create_dev_dandiset(*, name: str, email: str): | |
user=owner, embargo=False, version_name=name, version_metadata=version_metadata | ||
) | ||
|
||
uploaded_file = SimpleUploadedFile(name='foo/bar.txt', content=b'A' * 20) | ||
file_size = 20 | ||
file_content = b'A' * file_size | ||
uploaded_file = SimpleUploadedFile(name='foo/bar.txt', content=file_content) | ||
etag = '76d36e98f312e98ff908c8c82c8dd623-0' | ||
|
||
try: | ||
asset_blob = AssetBlob.objects.get(etag=etag) | ||
except AssetBlob.DoesNotExist: | ||
# Since the SimpleUploadedFile is non-zarr asset, validation fails | ||
# without a sha2_256 initially provided. | ||
sha256_hash = hashlib.sha256(file_content).hexdigest() | ||
Comment on lines
+44
to
+46
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. Can confirm this fixes the validation failure for me locally 👍 |
||
asset_blob = AssetBlob( | ||
blob_id=uuid4(), | ||
blob=uploaded_file, | ||
etag=etag, | ||
size=20, | ||
blob_id=uuid4(), blob=uploaded_file, etag=etag, size=file_size, sha256=sha256_hash | ||
) | ||
asset_blob.save() | ||
asset_metadata = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM node:20 | ||
|
||
# Set the working directory | ||
WORKDIR /usr/src/app | ||
|
||
# Copy package.json and install dependencies | ||
COPY package.json yarn.lock ./ | ||
RUN yarn install --production=false | ||
|
||
# Copy the rest of your application's code | ||
COPY . . | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8085 | ||
|
||
# Start the application | ||
CMD ["yarn", "run", "dev"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "dandi-archive", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"dev": "vite --host 0.0.0.0", | ||
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.
|
||
"build": "vite build", | ||
"preview": "vite preview --port 4173", | ||
"type-check": "vue-tsc --noEmit", | ||
|
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.
Because these are DEVELOPMENT (not DEPLOYMENT) instructions, I like when I could just copy/paste instructions. What about smth like
I also removed
chmod
hint -- must not be necessary if you give executable bit to that file in git.