Skip to content

Conversation

@ChristopherChudzicki
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki commented Sep 9, 2024

What are the relevant tickets?

For https://github.com/mitodl/hq/issues/5396 [the local development half]

Description (What does it do?)

Enables running NextJS frontend in docker locally.

How can this be tested?

On this branch:

  1. Stop your docker containers. Run docker compose up
  2. Run docker compose logs watch --follow --tail=500 in a new terminal to see the watch logs. You should see NextJS logs
  3. Visit http://open.odl.local:8062/ ... you should see the site. One way you will know it's the NextJS site—besides the docker logs—is to look at the initial HTML document, which will not be empty (as it is on main):
    Screenshot 2024-09-10 at 9 07 14 AM
  4. Ensure there are no CORS or CSRF errors. (There will be some other errors in the console we still need to deal with.)

@ChristopherChudzicki ChristopherChudzicki changed the base branch from main to nextjs September 9, 2024 21:08
@ChristopherChudzicki ChristopherChudzicki changed the title Cc/nextjs local dev docker [NextJS] Local docker setup Sep 9, 2024
Copy link
Contributor Author

@ChristopherChudzicki ChristopherChudzicki Sep 10, 2024

Choose a reason for hiding this comment

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

@jonkafton Opinion: We shouldn't use a frontends/main/.env.example file.

I know NextJS will use a .env file, but

  • the majority of the time, developers are using docker to run the app. Docker has the env vars in the environment, populated from env/shared.env, etc
  • If you're running outside of docker, let's use the same env files—env/shared.env, env/frontend.env, etc.
    • They can be loaded into shell automatically via some other tool, your choice. I use https://direnv.net/ for this (which @rhysyngsun suggested) and have been very happy with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, agree - all of these ended up being public, so can live in the committed env files.

@ChristopherChudzicki ChristopherChudzicki marked this pull request as ready for review September 10, 2024 13:14
@ChristopherChudzicki ChristopherChudzicki force-pushed the nextjs branch 2 times, most recently from 1f43fbb to f6c4d89 Compare September 11, 2024 13:22
@ChristopherChudzicki ChristopherChudzicki added the Needs Review An open Pull Request that is ready for review label Sep 11, 2024
const MITOL_API_BASE_URL = process.env.NEXT_PUBLIC_MITOL_API_BASE_URL
const IS_SERVER = typeof window === "undefined"
const MITOL_API_BASE_URL = IS_SERVER
? // NEXT_SERVER_MITOL_API_BASE_URL is generally only needed for local-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll hopefully end up addressing the API from within a local network (so the server isn't making API requests over the internet), though for now this holds true

@jonkafton jonkafton removed the Needs Review An open Pull Request that is ready for review label Sep 11, 2024
@ChristopherChudzicki ChristopherChudzicki merged commit 00aaea6 into nextjs Sep 11, 2024
ChristopherChudzicki added a commit that referenced this pull request Sep 13, 2024
* enable running nextjs in docker

* run storybook too
ChristopherChudzicki added a commit that referenced this pull request Sep 16, 2024
* enable running nextjs in docker

* run storybook too
jonkafton pushed a commit that referenced this pull request Sep 18, 2024
* enable running nextjs in docker

* run storybook too
ChristopherChudzicki added a commit that referenced this pull request Sep 19, 2024
* enable running nextjs in docker

* run storybook too
jonkafton pushed a commit that referenced this pull request Sep 23, 2024
* enable running nextjs in docker

* run storybook too
jonkafton pushed a commit that referenced this pull request Sep 23, 2024
* enable running nextjs in docker

* run storybook too
jonkafton pushed a commit that referenced this pull request Sep 24, 2024
* enable running nextjs in docker

* run storybook too
@odlbot odlbot mentioned this pull request Oct 22, 2024
74 tasks
@rhysyngsun rhysyngsun deleted the cc/nextjs-local-dev-docker branch February 7, 2025 20:35
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.

3 participants