Bundling NuxtJS dist directory using go:embed - go

I have a web app using a NuxtJS frontend being served from a Golang web micro-service.
I am using go:embed dist to ship the frontend assets into the web binary and running it all in a Docker container. For non-Gophers, go:embed is a directive that bundles files or directories into the Go binary. It's a compile error to use go:embed on a directory that doesn't exist.
Usually, you don't commit the dist directory to VCS, but if I don't, then all my CI builds fail because I cannot compile the web service since dist doesn't exist.
I tried adding a .gitignore inside the dist folder like this:
*
!.gitigore
I was hoping this would commit the empty dist folder to VCS, but still not commit any of the assets. This worked fine, until I ran the NuxtJS build and it deleted the .gitignore. I assume it deletes the whole directory and recreates it.
Does anybody know whether there is a configuration option to keep the dist folder around between builds, or at least to not delete the .gitignore within it?

Related

heroku: Deploying angular app inside spring boot app

I've one repo sunixi and it has two projects sun-angular(angular) and sun-admin(spring boot) in ts-admin i'm building ts-angular via executions and moving dist into resources/static of sun-admin project after that i'm building the sun-admin. On local enviroment it is working fine but how can i do same in heroku deployment.
structure of repo
sunixi
---sun-angular
---sun-admin
in sun-admin i'm setting workingDirectory as ../sun-angular but while deploying to heroku i'm getting
Cannot run program "npm" (in directory "/tmp/build_02607c07/sun-angular"): error=2, No such file or directory
If you are using a monorepository strategy, an option is to use subdir buildpack to select where is the path of your folder: https://github.com/timanovsky/subdir-heroku-buildpack
If you want to deploy backend and frontend in the same heroku app, the project folder should contains a npm package. Otherwise, i will not work.

Productive files from Laravel 8?

A quick question:
which files or directories from Laravel 8 needs to be transferred to a production system or Muße the entire files and directories?
Well, yes, you have to move all the files including the vendor directory which has all the php dependencies (unless you can run composer install in production, in that case there's no need to upload the vendor directory). If you have local logs and cache in the storage directory, you can omit those.
You will also need to create a new .env file for production.
And, if your are using JavaScript with Laravel Mix, you don't need to upload the node_modules folder, only the compiled js or css files.

Correct method of deploying Laravel 8 Application through cPanel

I designed a Laravel 8 app and successfully deployed it via cPanel. What I did was create a git repo in my cPanel. Connected that repo to my local app folder. Pushed the repo from my laptop and deployed it via git's post-receive hook to the public_html folder.
Now what I request you seniors to tell me, is what is the best practice of deploying the Laravel project.
a) should I deploy directly to my public_html folder via git repo (as I have done) or
b) should I deploy it to another folder and create a symlink pointing to public_html folder.
After deploying, i found that all my folders in storage folder where images are stored, have been deleted/removed. Should I again create those folders and try to create a symlink as I do in local project or there is some other procedure for doing that?
Regards
The public directory in your project needs to be the public facing directory. From what you have described, you need to point public_html to your public directory. So you probably will have to deploy to another directory.
You will need to recreate your storage directories and files, as it sounds like they are being ignored. Check your .gitignore file to make sure the proper files and directories are being tracked.

How to use modules replace functionality in cloud functions

I have a google cloud function that is a subdirectory in a repository. It uses the "Directory with source code" option in the settings menu. I keep getting this error on deploy:
Deployment failure:
Build failed: go: parsing /utils/pubsub/go.mod: open /utils/pubsub/go.mod: no such file or directory
go: error loading module requirements
I'm assuming that GCF does not upload the entire directory to the instance, but instead only the folder? This breaks the replace functionality of Go modules. Is there something I am doing wrong?
Link to the repo: https://github.com/FreekingDean/jeffbotgo/tree/5d735cc/slackevent
I work at Google and on this product.
Only the directory where you run gcloud is uploaded. There is no staging step beyond zipping the current directory and uploading it.
Notably, modules are preferred by the builder over vendor. If there is a go.mod, modules will be used. When you upload your function, it only includes the directory with your function at the root, not any directories one level up. So, when there is a go.mod and you have a replace directive pointing one level up, it will not work.
The solution for now with this layout is to vendor and not upload the go.mod/go.sum files. When using gcloud, you can create a .gcloudignore file to do this for you. See https://cloud.google.com/functions/docs/concepts/go-runtime#specifying_dependencies for more detail. Alternatively, modify your project to include any necessary helper packages in subdirectories.
I had the same issue today.
When reading thru the documentation for the 8th time i came across a warning box bellow the "Vendor directory" headline.
Warning: If your project has both a go.mod file and a vendor directory
at the root of your project, the vendor directory will be ignored
during deployment. You must use a .gcloudignore file to ignore the
go.mod file in order to ensure that your vendor directory is used
during deployment.
So basically once i added a .gcloudignore file with go.mod (will add go.sum as well) everything worked. So i guess if you have a go.mod file the cloud function will try to fetch dependencies instead of using the ones uploaded in the vendor folder.
I'm just guessing here tough.

how to deploy a custom sub-directory within the project with capistrano?

I couldn't find a way to do this yet with capistrano, but lets say I have a project like
project
project/src
project/Capfile
project/config/deploy.rb
project/config/deploy/production.rb
project/build
project/build/main.js
project/build/other_src.js
so the intention is to deploy only what I have within the /build sub directory within the project.
I realize I can just move the capistrano files to the build directory, but the directory is build and dropped every time I compile the project, so I need to kept the capistrano files within the root dir of the project.
Any advice on how to do it in Capistrano?
I've always deployed the entire project and then pointed my webserver at the relevant subfolder. Alternately, you can write a custom task to rework the data in the release path.

Resources