From 2484e4f1df75876cf01875f00e9fcd472c9360c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 23 Jul 2020 18:43:51 +0200 Subject: [PATCH] Moving maps to their own container --- .github/workflows/build-and-deploy.yml | 24 +++++++++ back/src/Controller/MapController.ts | 3 +- deeployer.libsonnet | 8 +++ docker-compose.yaml | 2 +- .../resources/items/computer/computer.png | Bin 0 -> 577 bytes .../items/computer/computer_atlas.json | 47 ++++++++++++++++++ .../items/computer/original/computer.png | Bin 0 -> 577 bytes .../computer/original/computer_atlas.json | 47 ++++++++++++++++++ .../items/computer/unpack/computer_off.png | Bin 0 -> 379 bytes .../items/computer/unpack/computer_on1.png | Bin 0 -> 492 bytes .../items/computer/unpack/computer_on2.png | Bin 0 -> 452 bytes front/src/Phaser/Items/Computer/computer.ts | 2 +- maps/{dist => }/.htaccess | 0 maps/Dockerfile | 9 ++++ .../Assets/Maps => maps}/Floor0/floor0.json | 0 .../Maps => maps}/Floor0/floortileset.png | Bin .../Floor0/tilesets_deviant_milkian_1.png | Bin .../Maps => maps}/Floor1/FloorTile_S.jpg | Bin .../Assets/Maps => maps}/Floor1/floor1.json | 0 .../Maps => maps}/Floor1/floortileset.png | Bin .../Floor1/tilesets_deviant_milkian_1.png | Bin .../Maps => maps}/Lyon/floortileset.png | Bin {back/src/Assets/Maps => maps}/Lyon/lyon.json | 0 .../Lyon/tilesets_deviant_milkian_1.png | Bin maps/objects/computer.ts | 2 +- 25 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 front/dist/resources/items/computer/computer.png create mode 100644 front/dist/resources/items/computer/computer_atlas.json create mode 100644 front/dist/resources/items/computer/original/computer.png create mode 100644 front/dist/resources/items/computer/original/computer_atlas.json create mode 100644 front/dist/resources/items/computer/unpack/computer_off.png create mode 100644 front/dist/resources/items/computer/unpack/computer_on1.png create mode 100644 front/dist/resources/items/computer/unpack/computer_on2.png rename maps/{dist => }/.htaccess (100%) create mode 100644 maps/Dockerfile rename {back/src/Assets/Maps => maps}/Floor0/floor0.json (100%) rename {back/src/Assets/Maps => maps}/Floor0/floortileset.png (100%) rename {back/src/Assets/Maps => maps}/Floor0/tilesets_deviant_milkian_1.png (100%) rename {back/src/Assets/Maps => maps}/Floor1/FloorTile_S.jpg (100%) rename {back/src/Assets/Maps => maps}/Floor1/floor1.json (100%) rename {back/src/Assets/Maps => maps}/Floor1/floortileset.png (100%) rename {back/src/Assets/Maps => maps}/Floor1/tilesets_deviant_milkian_1.png (100%) rename {back/src/Assets/Maps => maps}/Lyon/floortileset.png (100%) rename {back/src/Assets/Maps => maps}/Lyon/lyon.json (100%) rename {back/src/Assets/Maps => maps}/Lyon/tilesets_deviant_milkian_1.png (100%) 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 0000000000000000000000000000000000000000..cd3a261991801be8a1a79cd6a4ecb1656fec500e GIT binary patch literal 577 zcmV-H0>1r;P) z_y>hR@q`gY@w|$(;XC*1>V@psjnth@yDHtP+YRj3|nyiLH*mTJE@Z(AGU+ zL{U7=-8ZuI#1uvGB&2afM2rD?Tm=ONRmQ)NTEn0W`ZK|WwEFcd3Jj`Da3L?BMTbEd zbeL4o_b<7b*!kG&hx1Gh=NW@CXeL~FWf)YMu|eJH`YW7T>C{^XgEHtaQ?I-q&_BdHs4_4=wMKzKm4SI&1qB9GhAXcOgDL~_xC#mks?5K+;VuP(l4kh^iEayrv_vb( P00000NkvXXu0mjfFhUGc literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..cd3a261991801be8a1a79cd6a4ecb1656fec500e GIT binary patch literal 577 zcmV-H0>1r;P) z_y>hR@q`gY@w|$(;XC*1>V@psjnth@yDHtP+YRj3|nyiLH*mTJE@Z(AGU+ zL{U7=-8ZuI#1uvGB&2afM2rD?Tm=ONRmQ)NTEn0W`ZK|WwEFcd3Jj`Da3L?BMTbEd zbeL4o_b<7b*!kG&hx1Gh=NW@CXeL~FWf)YMu|eJH`YW7T>C{^XgEHtaQ?I-q&_BdHs4_4=wMKzKm4SI&1qB9GhAXcOgDL~_xC#mks?5K+;VuP(l4kh^iEayrv_vb( P00000NkvXXu0mjfFhUGc literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..544838fe0b24506c5934cf8fbc7574a7bd98d2fe GIT binary patch literal 379 zcmeAS@N?(olHy`uVBq!ia0vp^T0pG9!3HEdxHAHP6lZ})WHAE+-w_aIoT|+y&A`B@ z>*?Yc64Cm0#(uv;0V3`DrQ}-G1ER?a)SK<0SnWFt~zv#r*TkhPxT!AHf_lMg0rQR$DKHD(FTxU%% zkYU^~!+))CZdi5Eu2_pc=A3&j;#W_-J!d?#vn}$Bw`V0ozy|e+dmnpD@v&0uHFck` zLNK%!1NpxBp7H;mwkAIV+u;}UX1Fj{*B;c%y8C+ZgzeYmf3+X6+aHoG+&sfYw;^o% zUZxjUaTa&)uc$SKhFz@-4inQxn`HrY$F+K@OXTR(7OlImCbL-b`(^*|p9D$+9 N;OXk;vd$@?2>_4Go6P_K literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..e2492441e294b71049346902c083c246cc1d5eaa GIT binary patch literal 492 zcmV?00009a7bBm000ie z000ie0hKEb8vp*MgxL5L7NRJEA|#-MK)^;MZAAP7wKE{W zMyxE;hy;{W3TiB@B^E&tL_`dT4`9Tnut>8OW{kUW*3BwA%;4$ny@cExK4vouh9CeO z$8m%ZqS7MS?gqFgQm?O&pch56ZzUQELt zp@{np>u)Pj?Eyfd_eeRj!zd$z5v|eUMLn{_sE2AX<*H}4ZoloT=2w?J0PNjdcef?B z8kL5E_B-d@o0QmTR8mN1T(!)c?EjQORo4Bm+o;M|P?KJRvcHp4f7TeIp%$$cQ?8s9 z(wUCj`t`$LjL}dT^=2$+W>rrz*-!XOOSKZiycNw6OU2t0YJru|D&#Jaw0jY z^#o1z>b)9Dq_b|1ro7xoZuWY4qgy5NKy|<6{5Y`o5LXC^6HhH?00009a7bBm000ie z000ie0hKEb8vp^8j!h2Y^=l5rD4yYE5OfRYIl*i)OP4{60xm?CoxcdNPd$>AD+f?Eyfc_!2qG zhf$UnQd&cid!qsDdPS={=eI-qQFF_k0pR)RGTD~o)u=M`-+p+W+@vC(Mir%UO{-Pr zRNo|nf01vaQO3q$QX$5u(V}*}qMe)q5M$H=IJ&6z0nYYM0JwU%A+Fxp zvH^Ji{LnH!PQ)11&e4NI|BGm4a}9uoUG)d$MZL}dnMUvL{I4RF$zR%hpo-b|BoR5IVW@ocS^muqVP0000 { - 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) => {