Docker: How to get BrowserSync running on a CraftCMS container? - docker

I'm new to Docker. I'm trying to use it to develop CraftCMS. I found https://hub.docker.com/r/blackpepper/craftcms which works well, but I'd really like to add BrowserSync to it (so I need NodeJS in the container as well?).
I really have no idea where to begin. I've been creating Dockerfiles and docker-compose.yml files and just throwing random stuff at it... for instance in my Dockerfile I put:
FROM blackpepper/craftcms
FROM node
RUN npm install -g browser-sync
RUN npx browser-sync start --files=templates/index.twig,web/assets/style.css --proxy=http://localhost:8080
# the proxy url is where I can actually view the craftcms site in my browser
I'd really appreciate any guidance, especially if you have experience doing something like this.

After having struggled myself for years with setting up Node.js workflows including Browsersync and Gulp (or other node modules), I created an alternative that is muuch simpler to use and maintain.
I just depend on 3 binaries: inotifywait, xdotool and sassc.
If you want to know more, I have created a video showcasing the functionality.
You can check it here: https://youtu.be/tMW-xQZ6c1U
Hope that helps.

Related

How does Nix able to install individual NPM packages as standalone software?

CAVEAT: If you would like to use Serverless Framework with Nix/NixOS, this is not the way to do it: the package you end up with is outdated, and (as stated below) it probably won't work anyway. See thread on NixOS Discourse.
Wanted to try out Serverless via nix-shell so I looked it up, ran the command
nix-shell -v -p nodePackages.serverless
a̶n̶d̶ i̶t̶ w̶o̶r̶k̶s̶ f̶l̶a̶w̶l̶e̶s̶s̶l̶y̶.1
What makes this possible without requiring me to install Node manually to be able to run npm install -g serverless? (E.g., Is the node_modules folder somewhere in the Nix store? What happens if I nix-shell another Node package - will they share that same directory?)
[1]: It does not... See this Reddit thread; probable setuid issue. Still interested in the behind the scene stuff though.
This question is more like a todo because I really would like to figure it out myself but don't have the time for it right now...
This is possible because it was packaged with node2nix. This tool generates expressions that fetch the various packages and put them in a node_modules directory.
Indeed it's not perfect and some package need some extra fixing up to make them work well. The node2nix tooling could 'learn' from the cabal2nix integration in Nixpkgs to improve the quality of packaging and the Nixpkgs developer experience.

Making changes to a frontend repo, linked to a docker repo (0x Launch Kit)

I know this might seem like an obvious question and a bit general, but I just started playing around with the Launch Kit by 0x (https://github.com/0xProject/0x-launch-kit) and have successfully deployed the example app, but would now like to proceed and customize the frontend.
I see that the repository I linked above, used to build the app, is actually a docker repo for both the frontend and API repos:
https://github.com/0xProject/0x-launch-kit-frontend
https://github.com/0xProject/0x-api
Do I need to fork all three repos for this to work (docker, frontend and api) to my own GitHub account and make changes to the frontend repo? If so, do I need to change anything in the cloned docker repo for the app to use my new frontend code when building?
Would appreciate the help!
Another method is to fork the uikit and create a custom kit from it on the npmjs website. Then call it into to you project.
Catgirl is a good example of this in play.
Customising the frontend will require you to find and edit the correct files inside the node modules. Which is not recommended unless you know what you're doing. Note that 'yarn' or 'npm install' with undo all your changes you make to any node modules.
One way to go about it is to use the "patch-package" to patch the node modules after editing it. For example, "npx patch-package name-of-package". This is a tedious method.

setting up swagger 3 or OpenAPI in a gradle springboot api

Swagger 3 ? or Open API ..? 3? not sure what they're calling it. There doesn't seem to be a good or easy setup.
I'm looking to add it to my java project
I don't mind manually filling out the config for my controllers and in fact do not want it dynamically config'd
and I don't want a lot of extra fluff with it.
Their github hosts a number of different files and I'm not sure what I do and don't need.
The setup at:
https://github.com/swagger-api/swagger-ui/blob/master/docs/development/setting-up.md
I've run through the setup commands and started locally which returns 2 js files, 1 css, and the swagger.json.
Does anyone know if there's a gradle or maven import / line that I can just plop into my build and get the code I need?
Has anyone setup swagger 3 with just the bare minimum to host the ui page with their controller on a java/springboot app?
any help welcome.
git clone https://github.com/swagger-api/swagger-ui.git
cd swagger-ui
npm install
npm run dev

Is it possible to avoid updating drupal core with composer update?

I'm trying to build a docker container where the dockerfile installs a specific version of drupal, I copy over custom copies of composer.json/composer.lock and then do a composer update to download the contributed modules specified in these composer files. I know that ideally composer would also control core, but for this project, I'm trying to avoid that.
The problem I'm having is that composer update seems to also reinstall drupal, where I want the dockerfile to be in control of this and I'd like composer to just manage the modules.
Is this something I could do by modifying the composer files (so far tests have not worked)? It seems you can't specify a package for composer to ignore and where I see you can specify specific packages to update, that's not really a viable solution for this.
Thanks
OK, it's looking like the issue was the composer.lock/json files I was adding to run composer update were initially created by using composer create-project drupal-composer/drupal-project, which installed core and thus added it to the composer.lock/json files.
It seems that by just reinstalling the contributed modules with composer in a fresh drupal site (so simplified composer files) might be the answer.

OwinHost.exe from command line - how to make it start on a different port?

Yes, I have looked on google for this seeming simple question w/o much luck.
So my project includes the OwinHost (OwinHost.exe) NuGet package, and this has updated my project in such a way as to allow the Visual Studio IDE, via property pages, to specifically launch OwinHost.exe using whatever url:port I've specified on the 'Web' tab.. .. but since this is currently error-ing out and closing the cmd window before I can see the error.. I thought I'd try to run OwinHost.exe manually...
I know how to cd to my web project's bin folder and then call out to the appropriate packages subdir to OwinHost.exe to make it start listening for web requests. But, it listens on port :5000 and I want to change this.
Ugh.. just figured it out... the -u switch..
..\..\packages\OwinHost.3.1.0\tools\OwinHost.exe -u https://localhost:443/

Resources