How to deploy files of a folder into another one?

My problem is simple, I have a project, and in this project:

  • There is a project/js folder, with plenty of js files
  • There is a project/js-prod folder, with plenty of js files, but minified
  • I have, for the concerned project instance, two deployment instances: staging and prod.
  • Into staging, I want to deploy js, so I have set, for the staging deployment server: added project/js-prod to local excluded paths
  • Into prod, I want to deploy js-prod, but as js, so I have set, for the prod deployment server: added project/js to local excluded paths, added path mapping of local project/js-prod to server/project/js.

The problem: When I deploy to prod, I seemingly deploy js-prod twice, once into server/project/js; and once into server/project/js-prod. What am I missing?

12 comments
Comment actions Permalink

Is this the wrong place to post this kind of question?

0
Comment actions Permalink

Hi there,

Is this the wrong place to post this kind of question?

No. This is the right place for this kind of questions. I'm surprised that you had no answer here yet.

 

Regarding your issue: I normally either have minified files next to sources, just with .min part (e.g. .min.js etc) or selecting the right path based on a switch when rendering the view (i.e. script('path/to/script') that then decides what file to use, adds version/hash info query string etc etc))

With your setup/approach (should have really tested it first before giving these advices...):

  • That supposed to work (your current exclusions). Makes sense to report as a bug to PhpStorm Issue Tracker if nothing of the suggested will work.
  • Now, try to also exclude the remote path server/project/js-prod as well (just a thought; may help)
  • Another idea: why no make a symlink on a server ( server/project/js-prod --> server/project/js ) and deploy to the normal path as is?

 

A few questions though (as it may work  OK in one setup and not work in another):

  • What deployment do you use: FTP/SFTP/FTPS .. or maybe it's rsync?
  • How do you deploy: are you invoking Deploy on a current/selected files .. or on a parent or root folder?
  • Do you actually use Deploy to... or perhaps it's Sync with Deployed (that allows you to see what file will be uploaded/downloaded first etc)?
0
Comment actions Permalink

Cheers for your response and hints. Yes, the fact that I wasn't getting any answer made me think that I posted in the wrong forum. Regarding your questions:

  • I'm using an SFTP connection I've setup in PhpStorm (under Build, Execution, Deployment > Deployment) and deploy via that connection using rsync (by ticking the field "Use rsynch for upload/download). It's the same exact deployment configuration (SFTP + Use rsynch) as with the staging environment, and the js-prod is not deployed, as specified. The issue really is only with the deployment directory.
  • Depends, one time one thing, another time another thing. Can't tell about any difference regarding the result.
  • I use Deploy to...
0
Comment actions Permalink

Another difference I've noticed: In the Mappings configuration for staging, I have a single path mapping:

Local path: path/to/local/staging/project

Deployment path: /

Web path: /

 

In the mappings configuration for prod, I have two specified path mappings:

Local path: path/to/local/prod/project

Deployment path: /

Web path: /

 

Local path: path/to/local/prod/project/js-prod

Deployment path: /server/project/js

Web path: (none specified)

 

Is the first provided mapping maybe the reason ? I mean, the path exclusions should still prevent the js-prod folder, situated within path/to/local/prod/project/js-prod  from being deployed, even given the two path mappings above, no?

 

0
Comment actions Permalink

@Cbf Fcb

I'm using an SFTP connection I've setup in PhpStorm (under Build, Execution, Deployment > Deployment) and deploy via that connection using rsync

Try plain SFTP, not rsync. This might be a rsync integration issue / missed scenario.

Is the first provided mapping maybe the reason ? 

Rather unlikely. The path exclusion should take care.

Having 2 paths mappings is quite common (for a different reason, but still):

  •  mapping the usual "local_root/ " to "remote_root/ " using "/ " as a web path.
  • mapping "local_root/public/ " to "remote_root/public/ " using "/ " as a web path.

This way the IDE will know that when accessing the ROOT/public/image.jpg it should be accessible via domain.com/image.jpg URL (as public is a website root folder). The above setup does not cause any issues. But it is different from yours .. hence it's hard for me to say anything specific...

 

P.S. See if you get a response from JetBrains folks. If none by Tuesday -- use the "Submit a Request" link at the top of this page to make a Support Request ticket where you can privately provide more info / logs / etc.

0
Comment actions Permalink

I have done some experiments with plain FTP deployment .. and "Deployment | Upload to XXX" seems to work fine for me regardless of where it was invoked: in a file to upload current file, or when selecting the whole folder (inc parent folder) in the Project View panel.

BUT it does not work if I use "Deployment | Sync with Deployed to XXX" -- the path mapping gets ignored here...

TTT was the folder to test (located in the project root)

And these are the exclusions and mappings:

Proof (deployment logging):

 

I'm on Windows and do not have rsync so cannot test how it will work there. Try with just "plain" SFTP and see if it will make any difference.

0
Comment actions Permalink

I've tried it after disabling rsynch, hende deployment via SFTP, via many different ways (keyboard shortcuts, "Upload To.."; and that seemed to do the trick. Hence this indeed seems to be an rsynch issue!

0
Comment actions Permalink

Guys, thank you for your activity and sorry for the lack of reaction from our side, we are bit understaffed at the moment and trying to recover.

In the meantime, I have tried to play around with "Excluded paths" on rsync-enabled connection but was not able to reproduce the issue, everything that is excluded is actually excluded from upload for me.

There is an old ticket with ignored exclusions on Windows machines:
https://youtrack.jetbrains.com/issue/WI-63301/Exclude-paths-on-windows-are-not-properly-passed-to-rsync-command

According to the ticket details, it should be fixed already and, as I mentioned before, I was not able to reproduce it (I have a Windows client + Ubuntu SSH/Rsync server).

Just to confirm, what IDE version do you have?

0
Comment actions Permalink

Thanks for your reply; I'm using PHPStorm 2022.1.4, Build #PS-221.6008.16, built on July 20, 2022, on a  MacBook Pro (Retina, 13-inch, Early 2015), using macOS Monterey 12.5.1; does that help you?

0
Comment actions Permalink

Thank you for the update.

Even though the aforementioned issue seems to be fixed in earlier version, I was wondering if you could update to the most recent stable build (2022.3.2) and check if it is still reproducible for you there.

0
Comment actions Permalink

With PhpStorm 2022.3.2; Build #PS-223.8617.59, built on January 30, 2023; the issue persists. Concretely:

Again, our path configs are:

MAPPINGS:

Local Path                                          Deployment Path                 Web Path
/local/project/path                               /                                           /
/local/project/path/to/js-prod               /to/js             

Note that there's nothing specified for "Web Path" in the second line, leading to the warning "Web path is not specified for "local/project/path/to/js-prod"; but your docs state that this warning can be ignored.

EXCLUDED PATHS:

....
....
/local/project/path/to/js
....
....

Result: /local/project/path/to/js-prod  gets deployed to /to/js-prod on the server, and /to/js on the server remains as before deployment.

Note that the EXCLUDED PATHS exclude some further files which must not be deployed, and that actually works. So I assume your issue comes from combining all a path mapping, an excluded path, an rsynch uploads using SFTP for two concerned folders (js-prod and js, here). Like this, you may be able to test it. Please keep us posted, as this is a crucial part of our deployment procedures. If we're supposed to use it, we have to be able to rely on it.

How long will it take to fix this? For now we'll try it out via SFTP and turn off rsynch, but this makes the deployments a lot slower. Using rsynch is not an option for now, as its deployments seem to be unreliable when it comes to excluded paths... Any idea by which configs etc. these problems could be caused?

0
Comment actions Permalink

I have tried to reproduce it again but still no luck.


Here is the local structure (I am on Windows):
Here are my mappings:
Exclusions:
And upload result (nothing from "to/js-prod" is uploaded):
Rsync is on:

What am I missing?
Would it be possible to share a sample project with the needed file structure and configured deployment ("visible for this project", leave a dummy SSH config, I will replace it my server), so I could try it on my setup?

 

0

Please sign in to leave a comment.