Skip to content

feat(backend): migrate to s3 #8545

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

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft

feat(backend): migrate to s3 #8545

wants to merge 21 commits into from

Conversation

roschaefer
Copy link
Member

🍰 Pullrequest

Issues

  • None

Todo

  • None

@roschaefer roschaefer force-pushed the migrate-to-s3 branch 3 times, most recently from 97b8cae to f3d1dcd Compare May 14, 2025 12:06
@roschaefer roschaefer changed the title wip: Migrate to s3 feat(backend): Migrate to s3 May 14, 2025
roschaefer added a commit that referenced this pull request May 14, 2025
Side quest of #8545. Looks like this file is not being used at all.
roschaefer added a commit that referenced this pull request May 14, 2025
Side quest of #8545. Looks like this file is not being used at all.
roschaefer added a commit that referenced this pull request May 14, 2025
Side quest of #8545. Looks like this file is not being used at all.
@roschaefer roschaefer force-pushed the migrate-to-s3 branch 2 times, most recently from 636dff9 to 2d0074b Compare May 14, 2025 17:57
@roschaefer roschaefer changed the title feat(backend): Migrate to s3 feat(backend): migrate to s3 May 15, 2025
// eslint-disable-next-line @typescript-eslint/await-thenable
await getNeode().schema.install()

getNeode().schema.install()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you must wait it - it doesnt work properly if you don't - I tested it - see comment above

Copy link
Member Author

@roschaefer roschaefer May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, maybe their types are just broken. It does return a promise?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types are broken. It is a Promise thats returned. This library is just a nightmare.

export async function up(_next) {
if (CONFIG.NODE_ENV === 'test') {
// Let's skip this migration for simplicity.
// There is nothing to migrate in test environment and setting up the S3 services seems overkill.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree that it is not necessary for test environment to migrate stuff, but since the s3 will be the only option for image handling we need to set it up as well. The E2E tests for example test for correct behaviour if I am correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK! I can for sure setup a test S3 service - it might slow down CI a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


try {
// Implement your migration here.
await transaction.run(``)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suggest to just throw here and forget about it

@@ -0,0 +1,134 @@
/* eslint-disable @typescript-eslint/require-await */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we still support local images? You remove some parts of the corresponding code - the migration throws an error if you do not have an s3 configured.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitating to remove the code before the migration is done. Maybe I will remove it straight away when I refactor (e.g. pass s3Client via context) so I don't have to maintain it.

Copy link
Member

@ulfgebhardt ulfgebhardt May 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just for my understanding - its fine to keep the code for a moment for reference

export const sanitizeRelationshipType = (relationshipType: string) => {
// Cypher query language does not allow to parameterize relationship types
// See: https://github.com/neo4j/neo4j/issues/340
if (!['HERO_IMAGE', 'AVATAR_IMAGE'].includes(relationshipType)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not your problem, but there are solutions to this problem

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this code was here before. Maybe I can add this as a separate PR.

roschaefer added a commit that referenced this pull request May 16, 2025
Side quest of #8545. Looks like this file is not being used at all.
roschaefer added a commit that referenced this pull request May 21, 2025
Side quest of #8545. Looks like this file is not being used at all.
I think we can merge this already. The S3 client dependency is outdated
and since the code is behind a feature flag it doesn't get executed. Why
not merge it then?
roschaefer added 10 commits May 22, 2025 00:05
I think we can merge this already. The S3 client dependency is outdated
and since the code is behind a feature flag it doesn't get executed. Why
not merge it then?
    This is a work-in-progress. I'm already able to start minio and
    upload+delete pictures.

    Todos:
    * tests (manual if necessary)
    * look into `mergeImage`
    * in development the domain for the images is `minio` instead of `localhost`

    # commits

    * fix: order of cli command
    * fix build
    * feat: add required migration for s3 storage
    * refactor: more typescript fixes
    * refactor: DRY, typescript
    * fix docker build
    * build(backend): update aws s3 package
This will fix the problem of differing domains in docker-compose locally
but it also sets the ground for a later use of a image resize service.
TODOs:
* does it make sense to store with the image where it has been saved to?
* `await` delete callback
TODO:
* remove kubernetes code for uploads in the future
Side quest of #8545. Looks like this file is not being used at all.
roschaefer added a commit that referenced this pull request May 21, 2025
Side quest of #8545. Looks like this file is not being used at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants