Containers
Submission files

A typical submission to Sphere Engine Containers API is a part of a larger project. Such submissions are packages containing a number of files arranged in the directory tree. However, the submission doesn't need to contain all the project files, which would be wasteful. The submission should deliver only new or modified files in the ideal situation.

Consider an example project structure:

src
├── models
│   ├── Book.ts
│   ├── Bookstore.ts
│   └── User.ts
└── views
    ├── AddBook.tsx
    ├── EditBook.tsx
    ├── EditUser.tsx
    ├── Library.tsx
    └── User.tsx
test
└── models
    ├── Bookstore.ts
    └── User.ts
package.json
tsconfig.json

In the above project, there are many files in different directories, and this is only a sample to aid our discussion. Actual projects are much more complex. Usually, the submission affects only a small part of the project.

Let's assume that we would like to:

  • add a new test/models/Book.ts file,
  • edit the src/models/User.ts file,
  • edit the test/modes/User.ts file.

Our goal is to have the following project:

src
├── models
│   ├── Book.ts
│   ├── Bookstore.ts
│   └── User.ts          <-- modified by submission
└── views
    ├── AddBook.tsx
    ├── EditBook.tsx
    ├── EditUser.tsx
    ├── Library.tsx
    └── User.tsx
test
└── models
    ├── Book.ts          <-- added by submission
    ├── Bookstore.ts
    └── User.ts          <-- modified by submission
package.json
tsconfig.json

We intend to create a tar.gz archive containing all the files (i.e., src/models/Book.ts, src/models/User.ts, test/models/User.ts) and keep the directory structure. In other words, we want to create an archive of the following structure:

src
└── models
    ├── Book.ts
    └── User.ts
test
└── models
    └── User.ts

In addition, Sphere Engine Containers API follows the convention in which it is required to have an archive in a canonical form. The canonical form requires putting all submission files into a single directory named workspace, which should be placed in the root of the tar.gz archive.

Assuming we are in the directory directly above the src and the test directories, we can do it as follows:

tar -czf source.tar.gz --transform 's,^,workspace/,' ./src ./test

We should end up with the source.tar.gz archive that is ready to be submitted by the API method. The archive yields the following structure (note the added workspace directory in the root of the directory structure):

workspace
├── src
│   └── models
│       ├── Book.ts
│       └── User.ts
└── test
    └── models
        └── User.ts

Note: The presented method shows how to create an archive manually. While integrating Sphere Engine Containers, you can use any programming method to automate this process. For example, you can use PharData in PHP and tarfile in Python.