I have built a Node.js app and what I do to deploy is cd into my project's directory and run gcloud preview app deploy. This works, but in the files I also have a JSON file which acts like the database for my application, which I do not want updated on the site when I deploy.
I cannot seem to find any way of doing this.
Any idea?
There is skip_files directive in your app.yaml to exclude paths or files you do not want deployed.
But If you are working on a node.js project you would have to use .gcloudignore file which will specify which directories to exclude.
This .gcloudignore would prevent the upload of the node_modules/ directory and any files ending in ~:
node_modules/
*~
Reference to documentation:
1. https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore
2. https://cloud.google.com/appengine/docs/standard/nodejs/config/appref (search 'skip_files')
In this case, a .gcloudignore file would help by preventing the upload of any file or directory. The syntax is the same as the .gitignore file.
First you could make sure gcloudignore is enabled:
gcloud config list
If it is not, then you may enable it:
gcloud config set gcloudignore/enabled true
Some gcloud commands like gcloud functions deploy may automatically generate a .gcloudignore file.
The .gcloudignore file must reside in the project root folder.
Here is the .gcloudignore that is automatically generated by the gcloud function deploy command:
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
node_modules
This worked fine for me with a NodeJS project with the following structure:
~/Workspace/my-project $ tree -a
.
├── .idea
│ ├── func-project.iml
│ ├── misc.xml
│ ├── modules.xml
│ ├── vcs.xml
│ └── workspace.xml
├── .gcloudignore
├── index.js
├── package-lock.json
└── package.json
In this case, without the .gcloudignore this is what is deployed:
And with the following .gcloudignore:
.gcloudignore
.git
.gitignore
.idea
node_modules
package-lock.json
This is what is deployed:
See more on this.
I believe you will want to use the skip_files directive in your app.yaml to exclude paths or files you do not want deployed.
Something like:
skip_files:
- ^your_data_dir/.*\.json?
Related
In a Dist::Zilla-based distribution I would like to have some files that are only used for testing, but do not get installed. These are mockup libs that aren't needed for runtime.
How do I do that?
CPAN distributions never install the t and xt directories. You can put your tests and your mock libs into t.
As an example, take my module MooseX::LocalAttribute. In the dist, there is a t/, a t/lib and an xt/.
If you install this using cpanm -l into a local lib dir, you will see there are no tests installed. This happens automatically. It's just how CPAN works.
$ cpanm -l mylib MooseX::LocalAttribute
--> Working on MooseX::LocalAttribute
Fetching http://www.cpan.org/authors/id/S/SI/SIMBABQUE/MooseX-LocalAttribute-0.05.tar.gz ... OK
Configuring MooseX-LocalAttribute-0.05 ... OK
Building and testing MooseX-LocalAttribute-0.05 ... OK
Successfully installed MooseX-LocalAttribute-0.05
1 distribution installed
$ tree mylib
mylib
├── lib
│ └── perl5
│ ├── MooseX
│ │ └── LocalAttribute.pm
│ └── x86_64-linux
│ ├── auto
│ │ └── MooseX
│ │ └── LocalAttribute
│ └── perllocal.pod
└── man
└── man3
└── MooseX::LocalAttribute.3
9 directories, 3 files
Note that as long as stuff is in t/lib (or anywhere under t/, really), you do not have to hide the package names from the PAUSE indexer. It's smart enough to not find it.
I misunderstood the question. This answer is for the following question:
How do I exclude files from a Dist::Zilla based distribution so they don't get shipped at all?
You are probably using either the GatherDir or Git::GatherDir plugin to build your bundle. Both of them have an option exclude_filename that you can set in your dist.ini to not include a file in a bundle.
A common pattern is to exclude auto-generated files such as LICENSE or META.json, and then add them later with another plugin. But you don't have to do that, you can just exclude files completely.
A good example is the URI distribution. On metacpan, it does not include any text files in the bundle. But if you look at the repository on github, you can see there are various .txt files such as rfc2396.txt. The dist.ini contains the following lines.
[Git::GatherDir]
exclude_filename = LICENSE
exclude_filename = README.md
exclude_filename = draft-duerst-iri-bis.txt
exclude_filename = rfc2396.txt
exclude_filename = rfc3986.txt
exclude_filename = rfc3987.txt
As mentioned before, the LICENSE and README.md files will still appear in the final bundle, because they get added later via #Git::VersionManager.
This is a much asked question, but none of the solutions mentioned on SO have worked so far.
The folder structure is as follows:
project/
└── tests/
├── conftest.py
├── __init__.py
└── int_tests/
└── test_device.py
└── project_core/
└── tests/
├── conftest.py
├── __init__.py
└── int_tests/
└── test_device.py
import file mismatch:
imported module 'test_device' has this __file__ attribute:
/home/.../project/project_core/tests/int_tests/test_device.py
which is not the same as the test file we want to collect:
/home/.../project/tests/int_tests/test_device.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
Steps tried so far:
Removing pycache and pyc files.
Adding _init to each folder. (As is stated in pytest GIP)
Removing _init from each folder.
Do i need init files in each tests/subfolder?
The same error occurs with conftest.py as well. This error is not limited to vscode-pytest plugin, also occurs on the terminal.
PS : For CI purposes, the system is configured with docker & tox. Development is done in venv.
I'm trying to unpack .tar.gz file to my root during the building system, but it doesn't work because of an unclear reason for me. I did it in the same way as other recipes in my meta (which works fine), but in this case, I have an empty directory in the target system root. The recipe has the same name as tar.gz.
Based on Yocto Project Documentation and my other experience it should work fine. I tried to remove manually tmp, sstate-cache directories and rebuild system, but it doesn't change anything. The recipe is building, but the /my-app is empty. Can I force extract my archive?
Tree file:
├── meta-my
│ └── recipe-my-app-files
│ └── my-app
| └── my-app.bb
│ └── files
│ ├── my-app.tar.gz
....
my-app.bb
DESCRIPTION = "My Application package preinstall"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
RDEPENDS_my-app="bash qtdeclarative qtbase"
DEPENDS = "bash"
FILES_${PN} += "/my-app"
SRC_URI = "file://my-app.tar.gz"
BB_STRICT_CHECKSUM = "0"
S = "${WORKDIR}"
do_install() {
# Create directories
install -d ${D}/my-app
}
As mentionned in the link you provided that:
The unpack call automatically decompresses and extracts files with
".Z", ".z", ".gz", ".xz", ".zip", ".jar", ".ipk", ".rpm". ".srpm",
".deb" and ".bz2" extensions as well as various combinations of
tarball extensions.
it extracts .gz automatically into ${WORKDIR}.
The issue with your recipe is that you are creating /my-app but not filling it with any content.
Keep in mind that the compressed file is unpacked under ${WORKDIR}, so install it into ${D}/my-app:
do_install(){
# Create directories
install -d ${D}/my-app
# Install unpacked application
# install -m 0755 app ${D}/my-app
# ...
}
I do not know the content of your application, so change that according to it.
I want to avoid setting the default environment in CONFIG_EXTRA_ENV_SETTINGS, therefore I've set CONFIG_DEFAULT_ENV_FILE="uEnv.txt" and created that text file but bitbake doesn't find it:
make[1]: *** No rule to make target 'uEnv.txt', needed by 'include/generated/defaultenv_autogenerated.h'. Stop.
This is what the tree and the files look like:
└── u-boot
├── files
│ ├── ma1.cfg
│ └── uEnv.txt
└── u-boot-xlnx_%.bbappend
ma1.cfg:
CONFIG_USE_DEFAULT_ENV_FILE=y
CONFIG_DEFAULT_ENV_FILE="uEnv.txt"
u-boot-xlnx_%.bbappend:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI_append_tmc = " \
file://ma1.cfg \
file://uEnv.txt \
"
PACKAGE_BEFORE_PN += "${PN}-env"
RPROVIDES_${PN}-env += "u-boot-default-env"
I don't know where to put the uEnv.txt so it will be found. I already (blindly) tried to specify some different paths like CONFIG_DEFAULT_ENV_FILE="../uEnv.txt" but to no avail. I suspect that I need to put it somewhere in a do_configure_append() but I don't know where.
Searching for CONFIG_DEFAULT_ENV_FILE only yields results which state that it can be used to create the environment from a file[1], but unfortunately not how. Or, more precisely: How to use it with bitbake.
So I hope someone can help me here: What do I need to do so bitbake places the text file where make is going to find it?
[1] https://lists.denx.de/pipermail/u-boot/2018-March/323347.html
You need to pass your uEnv.txt file to the build directory to be found by Make.
You can do this in your bbappend file like:
do_configure_append() {
cp ${WORKDIR}/uEnv.txt ${S}
}
According to docs https://packaging.python.org/en/latest/distributing/#data-files
setuptools will honor data_files configed in setup.py. But i can't make it work. This is my setup.py:
setup(
name='booking_order',
version=version,
packages=find_packages(),
package_data={
'booking_order': ['fake_backends/static/*',
'scripts/*',
'*.sample'],
},
data_files=[
('/etc/booking', ['etc/booking.conf'])
],
This is the project's file tree:
.
├── booking_order
│ ├── __init__.py
│ ├── tests
│ │ ├── __init__.py
├── etc
│ ├── booking.conf
├── README.md
├── setup.py
The behavior is, if i run python setup.py install, file etc/booking.conf will got installed to /etc/booking. But if i first python setup.py sdist upload, then pip install booking_order, there will be an error "error: can't copy 'etc/booking.conf': doesn't exist or not a regular file".
I checked python setup.py sdist doesn't include files in etc at all.
EDIT:
it seems this is the answer: https://github.com/pypa/setuptools/issues/521
Answer it myself.
According to pypa, and non-package-data-files。"Setuptools doesn't support installing data files to some arbitrary location on a user’s machine; this is a feature, not a bug."
If one need to install files to locations like /etc, /usr/share, eg, then he/she may use data_files flag from distutils, which feature is not totally cleaned up from setuptools. "Not totally cleaned up" means you need to add those files to MANIFEST.in manually, which is different as in distutils.
Of course, it will be better if one can manage these configuration files with rpm or deb package system. For me it's just a temporary solution to use pip here.