Skip to content

[Feature] Base setup for Frontend Docker image#279

Merged
DxsSucuk merged 7 commits into
Ree6-Applications:masterfrom
jiriks74:master
Apr 28, 2024
Merged

[Feature] Base setup for Frontend Docker image#279
DxsSucuk merged 7 commits into
Ree6-Applications:masterfrom
jiriks74:master

Conversation

@jiriks74

Copy link
Copy Markdown
Contributor

As we discussed on Discord I've created a Docker image for Ree6's frontend. I added a workflow so it should build automatically with your backend image (maybe these images could be merged in the future? I think it's worth looking into).

I've also modified the README.md in the Frontend directory to have instructions on how to set up the frontend.

Please check the workflow. I haven't tested it but it should be OK.

@netlify

netlify Bot commented Jan 23, 2024

Copy link
Copy Markdown

Deploy Preview for ree6-backend ready!

Name Link
🔨 Latest commit 8ed52a6
🔍 Latest deploy log https://app.netlify.com/sites/ree6-backend/deploys/6621234e48ef720008c93c68
😎 Deploy Preview https://deploy-preview-279--ree6-backend.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment thread Frontend/docker/start.sh Outdated
Comment thread .github/workflows/dockerPush.yml Outdated

@DxsSucuk DxsSucuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After these changes the PR would be ready for a merge.

Comment thread Frontend/docker/start.sh Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file can now be removed or stripped down to write into a .env file. Because with the latest commit there is no reason to rebuild it since we now support enviroment values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dockerfile was modified to build the website with modifying only the adapter used.

Environment variables aren't loaded though.

I've tried setting BASE_PATH to "https://api.example.com" but from the browser console I see that it's still api.ree6.de.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've even tried VITE_API_URL which I saw in the commits

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's the command: docker run -it --rm --env VITE_API_URL="https://api.example.com" --env VITE_INVITE_URL="https://ree6.example.com/invite" -p 3000:3000 ree6/frontend

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very weird, try writing it into a .env file into the root of the Frontend, because thats how I did it to test it. And it worked completly fine for me. Also the env paths have to contain the VITE_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok I'll thy that one later, I'm learning for exams RN.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did it work for you?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello. I finally have my laptop back and I've been able to look at this.

AFAIK this cannot be done with how this project is set up. It's either hardcode it (and build it at every container start) or pass it through HTML I am not familiar with svelte so IDK how to do such a thing but in theory it should be possible for some sever-side component add BASE_PATH to the html in eg. <head><script>.

I have tried putting it into .env but it didn't work for me. Maybe it works at build time but once the site is built it doesn't do anything.

Comment thread .github/workflows/dockerPush.yml Outdated
Comment thread Frontend/docker/start.sh Outdated
echo "Patching svelte.config.js to use adapter-node..."
sed -i "s@import adapter from '\@sveltejs/adapter-auto';@import adapter from '\@sveltejs/adapter-node';@g" svelte.config.js

# Patch constants.ts to use our api url

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To work with the new enviroment stuff you would just need to do this:

rm .env
echo "VITE_API_URL=${API_URL}\nVITE_INVITE_URL=${INVITE_LINK}" > .env

I did not test this code for functionality, but it should be as easy as that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AFAIK the .env is used during build only?

@jiriks74

Copy link
Copy Markdown
Contributor Author

Hello. Sorry I went dark for a while - my laptop released the factory installed magic smoke so it's in RMA rn. I'll finish it once I get it back.

@DxsSucuk

Copy link
Copy Markdown
Member

As a follow up where you able to test it out? And if so did the enviroment variable change work for you?

@DxsSucuk DxsSucuk self-assigned this Apr 18, 2024
@DxsSucuk DxsSucuk added the p1 High priority. label Apr 18, 2024
@DxsSucuk DxsSucuk added this to the v4 Roadmap milestone Apr 18, 2024
@jiriks74

Copy link
Copy Markdown
Contributor Author

I was not yet able to make the frontend use the environment variables.

@DxsSucuk

Copy link
Copy Markdown
Member

In that case I will be checking it out today and trying to get it to work.

@DxsSucuk

Copy link
Copy Markdown
Member

Tested everything out, it seems like even thou I do not want to. We have to build the app on each start to ensure the Enviroment variables are being used. So I would ship out a pre built docker image with a bash script where the bash script rebuilds everything. The prebuilt stuff should be reused which allows quicker build times.

@DxsSucuk

Copy link
Copy Markdown
Member

I have finished a up fixing up the Dockerfile and readding the start.sh script. It seems to work now, without having to replace anything except the node processor.

@DxsSucuk
DxsSucuk merged commit 2d0dcfb into Ree6-Applications:master Apr 28, 2024
@jiriks74

Copy link
Copy Markdown
Contributor Author

Nice. I'll add the script back then. I'm on the way home so I'll look into it in cca 45 minutes.

@DxsSucuk

Copy link
Copy Markdown
Member

I already readded it, and its merged so all good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p1 High priority.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants