diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index e79fe2a9..edd7b553 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -79,6 +79,30 @@ jobs: tags: ${{ env.GITHUB_REF_SLUG }} add_git_labels: true + build-maps: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + + # Create a slugified value of the branch + - uses: rlespinasse/github-slug-action@master + + - name: "Build and push front image" + uses: docker/build-push-action@v1 + with: + dockerfile: maps/Dockerfile + path: maps/ + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: thecodingmachine/workadventure-maps + tags: ${{ env.GITHUB_REF_SLUG }} + add_git_labels: true + deeploy: needs: - build-front diff --git a/back/src/Controller/MapController.ts b/back/src/Controller/MapController.ts index e3730898..af2ba848 100644 --- a/back/src/Controller/MapController.ts +++ b/back/src/Controller/MapController.ts @@ -19,8 +19,9 @@ export class MapController { // Returns a map mapping map name to file name of the map getStartMap() { this.App.get("/start-map", (req: Request, res: Response) => { + let url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED; res.status(OK).send({ - mapUrlStart: req.headers.host + "/map/files" + URL_ROOM_STARTED, + mapUrlStart: url, startInstance: "global" }); }); diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 09074148..bb0ce34d 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -28,6 +28,14 @@ "API_URL": "api."+url } }, + "maps": { + "image": "thecodingmachine/workadventure-maps:"+tag, + "host": { + "url": "maps."+url, + "https": "enable" + }, + "ports": [80] + }, "website": { "image": "thecodingmachine/workadventure-website:"+tag, "host": { diff --git a/docker-compose.yaml b/docker-compose.yaml index 53208c76..6d9380b8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,7 +44,7 @@ services: DEBUG_MODE: "$DEBUG_MODE" HOST: "0.0.0.0" NODE_ENV: development - APACHE_DOCUMENT_ROOT: dist/ + #APACHE_DOCUMENT_ROOT: dist/ #APACHE_EXTENSIONS: headers #APACHE_EXTENSION_HEADERS: 1 STARTUP_COMMAND_0: sudo a2enmod headers diff --git a/front/dist/resources/items/computer/computer.png b/front/dist/resources/items/computer/computer.png new file mode 100644 index 00000000..cd3a2619 Binary files /dev/null and b/front/dist/resources/items/computer/computer.png differ diff --git a/front/dist/resources/items/computer/computer_atlas.json b/front/dist/resources/items/computer/computer_atlas.json new file mode 100644 index 00000000..881f1189 --- /dev/null +++ b/front/dist/resources/items/computer/computer_atlas.json @@ -0,0 +1,47 @@ +{ + "frames": [ + { + "filename": "computer_off", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on1", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 40 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on2", + "frame": { + "w": 42, + "h": 40, + "x": 42, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + } + ], + "meta": { + "description": "Atlas generado con Atlas Packer Gamma V2", + "web": "https://gammafp.github.io/atlas-packer-phaser/" + } +} \ No newline at end of file diff --git a/front/dist/resources/items/computer/original/computer.png b/front/dist/resources/items/computer/original/computer.png new file mode 100644 index 00000000..cd3a2619 Binary files /dev/null and b/front/dist/resources/items/computer/original/computer.png differ diff --git a/front/dist/resources/items/computer/original/computer_atlas.json b/front/dist/resources/items/computer/original/computer_atlas.json new file mode 100644 index 00000000..881f1189 --- /dev/null +++ b/front/dist/resources/items/computer/original/computer_atlas.json @@ -0,0 +1,47 @@ +{ + "frames": [ + { + "filename": "computer_off", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on1", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 40 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on2", + "frame": { + "w": 42, + "h": 40, + "x": 42, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + } + ], + "meta": { + "description": "Atlas generado con Atlas Packer Gamma V2", + "web": "https://gammafp.github.io/atlas-packer-phaser/" + } +} \ No newline at end of file diff --git a/front/dist/resources/items/computer/unpack/computer_off.png b/front/dist/resources/items/computer/unpack/computer_off.png new file mode 100644 index 00000000..544838fe Binary files /dev/null and b/front/dist/resources/items/computer/unpack/computer_off.png differ diff --git a/front/dist/resources/items/computer/unpack/computer_on1.png b/front/dist/resources/items/computer/unpack/computer_on1.png new file mode 100644 index 00000000..e2492441 Binary files /dev/null and b/front/dist/resources/items/computer/unpack/computer_on1.png differ diff --git a/front/dist/resources/items/computer/unpack/computer_on2.png b/front/dist/resources/items/computer/unpack/computer_on2.png new file mode 100644 index 00000000..f563b759 Binary files /dev/null and b/front/dist/resources/items/computer/unpack/computer_on2.png differ diff --git a/front/src/Phaser/Items/Computer/computer.ts b/front/src/Phaser/Items/Computer/computer.ts index 99eddbb7..7ea7b318 100644 --- a/front/src/Phaser/Items/Computer/computer.ts +++ b/front/src/Phaser/Items/Computer/computer.ts @@ -8,7 +8,7 @@ import {ActionableItem} from "../ActionableItem"; export default { preload: (loader: Phaser.Loader.LoaderPlugin): void => { - loader.atlas('computer', 'http://maps.workadventure.localhost/computer/computer.png', 'http://maps.workadventure.localhost/computer/computer_atlas.json'); + loader.atlas('computer', '/resources/items/computer/computer.png', '/resources/items/computer/computer_atlas.json'); }, create: (scene: GameScene): void => { diff --git a/maps/dist/.htaccess b/maps/.htaccess similarity index 100% rename from maps/dist/.htaccess rename to maps/.htaccess diff --git a/maps/Dockerfile b/maps/Dockerfile new file mode 100644 index 00000000..550d87f1 --- /dev/null +++ b/maps/Dockerfile @@ -0,0 +1,9 @@ +# we are rebuilding on each deploy to cope with the API_URL environment URL +FROM thecodingmachine/nodejs:12-apache + +COPY --chown=docker:docker . . +#RUN yarn install + +#ENV NODE_ENV=production +#ENV STARTUP_COMMAND_1="yarn run build" +#ENV APACHE_DOCUMENT_ROOT=dist/ diff --git a/back/src/Assets/Maps/Floor0/floor0.json b/maps/Floor0/floor0.json similarity index 100% rename from back/src/Assets/Maps/Floor0/floor0.json rename to maps/Floor0/floor0.json diff --git a/back/src/Assets/Maps/Floor0/floortileset.png b/maps/Floor0/floortileset.png similarity index 100% rename from back/src/Assets/Maps/Floor0/floortileset.png rename to maps/Floor0/floortileset.png diff --git a/back/src/Assets/Maps/Floor0/tilesets_deviant_milkian_1.png b/maps/Floor0/tilesets_deviant_milkian_1.png similarity index 100% rename from back/src/Assets/Maps/Floor0/tilesets_deviant_milkian_1.png rename to maps/Floor0/tilesets_deviant_milkian_1.png diff --git a/back/src/Assets/Maps/Floor1/FloorTile_S.jpg b/maps/Floor1/FloorTile_S.jpg similarity index 100% rename from back/src/Assets/Maps/Floor1/FloorTile_S.jpg rename to maps/Floor1/FloorTile_S.jpg diff --git a/back/src/Assets/Maps/Floor1/floor1.json b/maps/Floor1/floor1.json similarity index 100% rename from back/src/Assets/Maps/Floor1/floor1.json rename to maps/Floor1/floor1.json diff --git a/back/src/Assets/Maps/Floor1/floortileset.png b/maps/Floor1/floortileset.png similarity index 100% rename from back/src/Assets/Maps/Floor1/floortileset.png rename to maps/Floor1/floortileset.png diff --git a/back/src/Assets/Maps/Floor1/tilesets_deviant_milkian_1.png b/maps/Floor1/tilesets_deviant_milkian_1.png similarity index 100% rename from back/src/Assets/Maps/Floor1/tilesets_deviant_milkian_1.png rename to maps/Floor1/tilesets_deviant_milkian_1.png diff --git a/back/src/Assets/Maps/Lyon/floortileset.png b/maps/Lyon/floortileset.png similarity index 100% rename from back/src/Assets/Maps/Lyon/floortileset.png rename to maps/Lyon/floortileset.png diff --git a/back/src/Assets/Maps/Lyon/lyon.json b/maps/Lyon/lyon.json similarity index 100% rename from back/src/Assets/Maps/Lyon/lyon.json rename to maps/Lyon/lyon.json diff --git a/back/src/Assets/Maps/Lyon/tilesets_deviant_milkian_1.png b/maps/Lyon/tilesets_deviant_milkian_1.png similarity index 100% rename from back/src/Assets/Maps/Lyon/tilesets_deviant_milkian_1.png rename to maps/Lyon/tilesets_deviant_milkian_1.png diff --git a/maps/objects/computer.ts b/maps/objects/computer.ts index 145d19df..3c48f91a 100644 --- a/maps/objects/computer.ts +++ b/maps/objects/computer.ts @@ -42,7 +42,7 @@ class MySprite extends Sprite { export default { preload: (loader: Phaser.Loader.LoaderPlugin) => { - loader.atlas('computer', 'http://maps.workadventure.localhost/computer/computer.png', 'http://maps.workadventure.localhost/computer/computer_atlas.json'); + loader.atlas('computer', '/resources/items/computer/computer.png', '/resources/items/computer/computer_atlas.json'); }, create: (scene: Scene) => {