@dcl/asset-packs 0.0.0-20230908135400.commit-e2c5b3c → 0.0.0-20230911215327.commit-4ff713d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +7 -0
- package/Dockerfile +15 -0
- package/README.md +27 -7
- package/docker-compose.yml +56 -0
- package/entrypoint.sh +3 -0
- package/minio-mc-entrypoint.sh +21 -0
- package/package.json +5 -2
- package/server.ts +31 -0
package/.dockerignore
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
FROM node:18-alpine
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
COPY package.json /app/package.json
|
|
6
|
+
COPY package-lock.json /app/package-lock.json
|
|
7
|
+
|
|
8
|
+
RUN npm ci
|
|
9
|
+
|
|
10
|
+
COPY . /app
|
|
11
|
+
|
|
12
|
+
# Dependencies to run an http server and serve the catalog and assets
|
|
13
|
+
RUN npm install concurrently
|
|
14
|
+
|
|
15
|
+
ENTRYPOINT ["./entrypoint.sh"]
|
package/README.md
CHANGED
|
@@ -25,20 +25,40 @@ Every [release](https://github.com/decentraland/asset-packs/releases) will be de
|
|
|
25
25
|
You can develop this repo locally and test it within the Web Editor by doing the following:
|
|
26
26
|
|
|
27
27
|
Go to this repo in your machine and do this:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
|
|
29
|
+
#### Using the command line
|
|
30
|
+
|
|
31
|
+
- To start the SDK7 scene and watch for changes:
|
|
32
|
+
1. Run `npm run start:lib` to watch for changes.
|
|
33
|
+
2. Run `npm run start:js` to start running the SDK7 scene locally (by default on port `8000`).
|
|
34
|
+
3. Run `npm link` to allow other projects to symlink to this one.
|
|
35
|
+
4. Copy the path to the `bin/index.js` in this repo (something like `/Users/my-user/path/to/asset-packs/bin/index.js`).
|
|
36
|
+
|
|
37
|
+
- To start the catalog server:
|
|
38
|
+
1. Set the `AWS_ACCESS_KEY_ID` env var in `.env` to be your AWS access key.
|
|
39
|
+
2. Set the `AWS_SECRET_ACCESS_KEY` env var in `.env` to be your AWS secret key.
|
|
40
|
+
3. Set the `S3_BUCKET_NAME` env var in `.env` to be your S3 bucket.
|
|
41
|
+
4. Set the `AWS_STORAGE_URL` env var in `.env` to be your custom S3 object server.
|
|
42
|
+
5. Set the `CATALOG_SERVER_PORT` env var in `.env` to be `8002` (this is the catalog server we will start in the next step).
|
|
43
|
+
6. Run `npm run start:catalog` to start running an http server to serve the catalog.json and the asset-packs content from a custom S3 object server (by default on port `8002`).
|
|
44
|
+
|
|
45
|
+
#### Using Docker
|
|
46
|
+
|
|
47
|
+
If you have docker running on your device, you can start all these services using the `docker-compose.yml` file in this repo by running: `docker-compose up`.
|
|
48
|
+
|
|
49
|
+
This will start the SDK7 scene and the catalog server with a minio S3 server to store the assets locally.
|
|
32
50
|
|
|
33
51
|
Go the `js-sdk-toolchain` repo in your machine and do this:
|
|
52
|
+
|
|
34
53
|
1. Run `cd packages/@dcl/inspector`.
|
|
35
54
|
2. Run `npm link @dcl/asset-packs` to symlink to your local repository
|
|
36
55
|
3. Run `npm start` to start a local dev server. It should start by default on port `8000` but since we are already using it for the SDK7 scene, it will start on port `8001`.
|
|
37
56
|
|
|
38
57
|
Go to the `builder` repo in your machine and do this:
|
|
58
|
+
|
|
39
59
|
1. Set the `REACT_APP_INSPECTOR_PORT` env var in `.env` to be `8001` (this is the `@dcl/inspector` dev server we started in the previous section).
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
60
|
+
2. Set the `REACT_APP_BIN_INDEX_JS_DEV_PORT` to the port where the SDK7 started running (by defualt `8000`).
|
|
61
|
+
3. Set the `REACT_APP_BIN_INDEX_JS_DEV_PATH` env var in `.env` to the path to the `bin/index.js` that you copied in the first section or if you're using docker, set the path to be `/app/bin/index.js`.
|
|
62
|
+
4. Run `npm start` to start the builder local server which should start on port `3000`
|
|
43
63
|
|
|
44
64
|
Now you are all set, you can start developing the SDK7 scene in this repo, use it from the local Builder and test it by previewing the scene, which should use your local Builder Server serving the development javascript files.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Utilitarian compose file to locally run required external services
|
|
2
|
+
# required by the asset-packs. Just by running `docker-compose up`
|
|
3
|
+
# you will have a http-server and an s3 compatible local object storage
|
|
4
|
+
# ready to be used.
|
|
5
|
+
|
|
6
|
+
version: '3.8'
|
|
7
|
+
|
|
8
|
+
services:
|
|
9
|
+
# HTTP server that serves the SDK7 scene locally via http://localhost:8000.
|
|
10
|
+
# HTTP server that serves the catalog and asset-packs via http://localhost:8002.
|
|
11
|
+
asset-packs:
|
|
12
|
+
build: .
|
|
13
|
+
env_file:
|
|
14
|
+
- .env
|
|
15
|
+
ports:
|
|
16
|
+
- 8000:8000
|
|
17
|
+
- 8002:8002
|
|
18
|
+
volumes:
|
|
19
|
+
- ./packs:/app/packs
|
|
20
|
+
- ./scripts:/app/scripts
|
|
21
|
+
- ./src:/app/src
|
|
22
|
+
- ./server.ts:/app/server.ts
|
|
23
|
+
- ./entrypoint.sh:/app/entrypoint.sh
|
|
24
|
+
links:
|
|
25
|
+
- minio
|
|
26
|
+
|
|
27
|
+
# Object storage compatible with aws-sdk.
|
|
28
|
+
# Comes with a UI that can be accessed via http://localhost:9001.
|
|
29
|
+
# https://min.io/
|
|
30
|
+
minio:
|
|
31
|
+
image: minio/minio
|
|
32
|
+
environment:
|
|
33
|
+
- MINIO_ROOT_USER=admin
|
|
34
|
+
- MINIO_ROOT_PASSWORD=password
|
|
35
|
+
ports:
|
|
36
|
+
- 9000:9000
|
|
37
|
+
- 9001:9001
|
|
38
|
+
volumes:
|
|
39
|
+
- minio_data:/data
|
|
40
|
+
command: server /data --console-address ":9001"
|
|
41
|
+
|
|
42
|
+
# Companion for the minio service in charge of initialization and
|
|
43
|
+
# provides an mc client for operating directly with the storage
|
|
44
|
+
# https://docs.min.io/minio/baremetal/reference/minio-cli/minio-mc.html
|
|
45
|
+
minio-mc:
|
|
46
|
+
image: minio/mc
|
|
47
|
+
depends_on:
|
|
48
|
+
- minio
|
|
49
|
+
env_file:
|
|
50
|
+
- .env
|
|
51
|
+
volumes:
|
|
52
|
+
- ./minio-mc-entrypoint.sh:/scripts/entrypoint.sh
|
|
53
|
+
entrypoint: /scripts/entrypoint.sh
|
|
54
|
+
|
|
55
|
+
volumes:
|
|
56
|
+
minio_data:
|
package/entrypoint.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Required as the minio service on the docker-compose file might
|
|
4
|
+
# not be completely up on the execution of this file.
|
|
5
|
+
sleep 5
|
|
6
|
+
|
|
7
|
+
# Create an alias to the minio service so it can be accessed easily
|
|
8
|
+
mc alias set minio http://minio:9000 admin password
|
|
9
|
+
|
|
10
|
+
# Check if the bucket already exists
|
|
11
|
+
if mc find minio/$S3_BUCKET_NAME ; then
|
|
12
|
+
echo "Bucket \"$S3_BUCKET_NAME\" already exists, no need to create it again"
|
|
13
|
+
else
|
|
14
|
+
# Create the bucket and set the policy to public so anything can
|
|
15
|
+
# be downloaded or uploaded
|
|
16
|
+
mc mb minio/$S3_BUCKET_NAME
|
|
17
|
+
mc anonymous set public minio/$S3_BUCKET_NAME
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Keep the service running so it can be accessed later with docker-compose exec
|
|
21
|
+
tail -f /dev/null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/asset-packs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20230911215327.commit-4ff713d",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/definitions.js",
|
|
6
6
|
"typings": "dist/definitions.d.ts",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"start": "npm run start:js & npm run start:lib",
|
|
13
13
|
"start:js": "sdk-commands start",
|
|
14
14
|
"start:lib": "npm run build:lib -- --watch",
|
|
15
|
+
"start:catalog": "npm run catalog && npm run upload && ts-node --project tsconfig.scripts.json server.ts",
|
|
15
16
|
"build:js": "sdk-commands build",
|
|
16
17
|
"build:lib": "tsc --project tsconfig.lib.json",
|
|
17
18
|
"build": "npm run build:js && npm run build:lib"
|
|
@@ -41,6 +42,8 @@
|
|
|
41
42
|
"p-queue": "^7.4.1",
|
|
42
43
|
"prettier": "^3.0.2",
|
|
43
44
|
"rimraf": "^5.0.1",
|
|
45
|
+
"serve": "^14.2.1",
|
|
46
|
+
"serve-handler": "^6.1.5",
|
|
44
47
|
"ts-node": "^10.9.1",
|
|
45
48
|
"typescript": "^5.1.6"
|
|
46
49
|
},
|
|
@@ -52,5 +55,5 @@
|
|
|
52
55
|
"semi": false,
|
|
53
56
|
"printWidth": 80
|
|
54
57
|
},
|
|
55
|
-
"commit": "
|
|
58
|
+
"commit": "4ff713d51c298c8147cf59aa173b713355de3443"
|
|
56
59
|
}
|
package/server.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const handler = require('serve-handler')
|
|
2
|
+
const http = require('http')
|
|
3
|
+
const dotenv = require('dotenv')
|
|
4
|
+
|
|
5
|
+
dotenv.config()
|
|
6
|
+
|
|
7
|
+
const serverHost = process.env.SERVER_HOST || '0.0.0.0'
|
|
8
|
+
const serverPort = process.env.CATALOG_SERVER_PORT || 8002
|
|
9
|
+
const awsStorageUrl = process.env.AWS_STORAGE_URL || ''
|
|
10
|
+
const s3BucketName = process.env.S3_BUCKET_NAME || 'asset-packs'
|
|
11
|
+
|
|
12
|
+
const server = http.createServer((request: any, response: any) => {
|
|
13
|
+
response.setHeader('Access-Control-Allow-Origin', '*')
|
|
14
|
+
response.setHeader('Access-Control-Allow-Methods', '*')
|
|
15
|
+
|
|
16
|
+
return handler(request, response, {
|
|
17
|
+
redirects: [
|
|
18
|
+
{
|
|
19
|
+
source: '/contents/:hash',
|
|
20
|
+
destination: `${awsStorageUrl.replace(
|
|
21
|
+
/:(?=\d)/,
|
|
22
|
+
'\\:', // Parse the port dots
|
|
23
|
+
)}/${s3BucketName}/contents/:hash`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
server.listen(serverPort, serverHost, () => {
|
|
30
|
+
console.log(`Catalog server running at http://${serverHost}:${serverPort}`)
|
|
31
|
+
})
|