Skip to content
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

cleanup, local development fixes and start best practices #453

Merged
merged 4 commits into from
Nov 11, 2023

Conversation

fcaps
Copy link
Collaborator

@fcaps fcaps commented Nov 10, 2023

Cleanup, local development improvements and applying some best practices

  • removed some unused yarn deps (via npm_check)
  • added missing deps (grunt did not complain on concat, but files where missing)
  • removed Procfile (was prob. a leftover of a Heroku trail)
  • removed .dockerignore, since it is doing nothing for the build
  • fixed all of the grunt commands (that are used)
  • removed grunt node-inspector -> unused
  • added npm_check to find unused yarn deps and updates
  • Dockerfile was updated to include some of the best practices for node-containers
  • Docker compose was added for easy development with the faf-stack
  • Readme updated to include local docker env setup
  • Express port is now defaulting to 3000
  • OAUTH_PUBLIC_URL was intruduced for docker environments (container -> container vs brower -> container) urls
  • unused js files removed (no reference in the code, or empty files)

@fcaps
Copy link
Collaborator Author

fcaps commented Nov 10, 2023

we can split this PR into multiple smaller ones, but keeping all the things in my head (what js file can be deleted etc,) was too much for me.

- removed some unused yarn deps (via npm_check)
- added missing deps (grunt did not complain on concat, but files where missing)
- removed Procfile (was prob. a leftover of a Heroku trail)
- removed .dockerignore, since it is doing nothing for the build
- fixed all of the grunt commands (that are used)
- removed grunt node-inspector -> unused
- added npm_check to find unused yarn deps and updates
- Dockerfile was updated to include some of the best practices for node-containers
- Docker compose was added for easy development with the faf-stack
- Readme updated to include local docker env setup
- Express port is now defaulting to 3000
- OAUTH_PUBLIC_URL was intruduced for docker environments (container -> container vs brower -> container) urls
- unused js files removed (no reference in the code, or empty files)
@fcaps fcaps force-pushed the feature/update_local_development branch from 8e6c0c1 to 7a4ed4b Compare November 10, 2023 18:15
.dockerignore Outdated
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ignoring node_modules did nothing for the build nor the local env

TOKEN_LIFESPAN=43200
CLAN_INVITES_LIFESPAN_DAYS=30
EXTRACTOR_INTERVAL=5
PLAYER_COUNT_INTERVAL=15
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we should also update the faf-stack to include some of the fixes from here.

RUN yarn --prod

CMD PORT=3000 npm start
CMD ["dumb-init", "node", "express.js"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ENV NODE_ENV development
WORKDIR /code

CMD ["dumb-init", "./node_modules/.bin/grunt", "concurrent"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

multistage was actually not beneficial, so i decided to create a new dockerfile for local-dev

Procfile Outdated
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we are not using heroku somehow, right?

@@ -17,9 +17,10 @@ app.locals.clanInvitations = {};
require('dotenv').config();
//Define environment variables with default values
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
process.env.PORT = process.env.PORT || '4000';
process.env.PORT = process.env.PORT || '3000';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in every .env file i could found we setting the PORT env, just because we have this fallback here.

@@ -227,7 +228,7 @@ app.get('/login', passport.authenticate('faforever'));
passport.use('faforever', new OidcStrategy({
issuer: process.env.OAUTH_URL + '/',
tokenURL: process.env.OAUTH_URL + '/oauth2/token',
authorizationURL: process.env.OAUTH_URL + '/oauth2/auth',
authorizationURL: process.env.OAUTH_PUBLIC_URL + '/oauth2/auth',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

a browser can not resolve the docker name aka "http://faf-ory-hydra:4444", so this is needed for docker environments, this needs also be fixed in the faf-stack

Copy link
Member

@Sheikah45 Sheikah45 left a comment

Choose a reason for hiding this comment

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

I am not as familiar with grunt so can't comment too much on that

.env.example Outdated Show resolved Hide resolved
@@ -0,0 +1,33 @@
# node env is set statically to "development" in the dockerfile, you could override it here.
Copy link
Member

Choose a reason for hiding this comment

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

What was the thinking with having both a .env.template and .env.fafstack? It seems a little redundant

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

env.example is for local development (without docker and a faf-stack)

docker-compose.yml Show resolved Hide resolved
grunt/concat.js Outdated
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

none of the removed files where used, sometimes they where just empty after #410

@@ -1,6 +1,6 @@
module.exports = {
dev: {
tasks: ['nodemon:debug', 'concat:js', 'uglify:dev', 'watch'],
tasks: ['nodemon', 'concat', 'watch'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

uglify is not needed on dev, and calling a taks without :, just executes all tasks

@Sheikah45 Sheikah45 merged commit d730a2c into FAForever:develop Nov 11, 2023
2 checks passed
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