From bce5088d3cd2b1a1d94065e555e3adaf8efe73ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 25 Oct 2022 18:43:36 +0100 Subject: [PATCH] Front dockerfile (#88) * readding react-native-paper because expo build need it * added Dockerfile with nginx.conf for hosting * added front to docker-compose prod --- docker-compose.yml | 6 ++++++ front/.dockerignore | 4 ++++ front/Dockerfile | 18 ++++++++++++++++ front/nginx.conf | 14 +++++++++++++ front/package.json | 1 + front/yarn.lock | 51 ++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 front/.dockerignore create mode 100644 front/Dockerfile create mode 100644 front/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index a80b7bf..c11018d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,3 +16,9 @@ services: - POSTGRES_DB=${POSTGRES_DB} ports: - "5432:5432" + front: + build: ./front + ports: + - "8080:80" + depends_on: + - "back" diff --git a/front/.dockerignore b/front/.dockerignore new file mode 100644 index 0000000..d1265c1 --- /dev/null +++ b/front/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +.expo/ +.idea/ +.vscode/ \ No newline at end of file diff --git a/front/Dockerfile b/front/Dockerfile new file mode 100644 index 0000000..df325fd --- /dev/null +++ b/front/Dockerfile @@ -0,0 +1,18 @@ +# a Dockerfile to build the expo web app and serve it with nginx +# +# Build the app +FROM node:16-alpine as build +WORKDIR /app +COPY package.json yarn.lock ./ +RUN yarn install +# install expo cli +RUN yarn global add expo-cli +# add sharp-cli (^2.1.0) for faster image processing +RUN yarn global add sharp-cli@^2.1.0 +COPY . . +RUN expo build:web + +# Serve the app +FROM nginx:1.21-alpine +COPY --from=build /app/web-build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/front/nginx.conf b/front/nginx.conf new file mode 100644 index 0000000..ad9c65c --- /dev/null +++ b/front/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 80; + root /usr/share/nginx/html; + + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location /api/ { + proxy_pass http://back:3000/; + } +} \ No newline at end of file diff --git a/front/package.json b/front/package.json index 3c3570b..f553297 100644 --- a/front/package.json +++ b/front/package.json @@ -34,6 +34,7 @@ "react-dom": "17.0.2", "react-i18next": "^11.18.3", "react-native": "0.68.2", + "react-native-paper": "^4.12.5", "react-native-safe-area-context": "4.2.4", "react-native-screens": "~3.11.1", "react-native-super-grid": "^4.6.1", diff --git a/front/yarn.lock b/front/yarn.lock index 2cc7e61..eab0c20 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -1080,6 +1080,14 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@callstack/react-theme-provider@^3.0.7": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@callstack/react-theme-provider/-/react-theme-provider-3.0.8.tgz#d0d7ac71e422133c5f7b78f4c4aa1bc57f156f50" + integrity sha512-5U231sYY2sqQOaELX0WBCn+iluV8bFaXIS7em03k4W5Xz0AhGvKlnpLIhDGFP8im/SvNW7/2XoR0BsClhn9t6Q== + dependencies: + deepmerge "^3.2.0" + hoist-non-react-statics "^3.3.0" + "@cnakazawa/watch@^1.0.3": version "1.0.4" resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a" @@ -3940,7 +3948,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0: +color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -3959,11 +3967,27 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== -color-name@~1.1.4: +color-name@^1.0.0, color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +color-string@^1.6.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" + integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== + dependencies: + color-name "^1.0.0" + simple-swizzle "^0.2.2" + +color@^3.1.2: + version "3.2.1" + resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" + integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== + dependencies: + color-convert "^1.9.3" + color-string "^1.6.0" + colorette@^1.0.7: version "1.4.0" resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" @@ -5575,6 +5599,11 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== +is-arrayish@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" + integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== + is-buffer@^1.1.5, is-buffer@~1.1.1, is-buffer@~1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" @@ -8126,7 +8155,7 @@ react-native-gradle-plugin@^0.0.6: resolved "https://registry.yarnpkg.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.0.6.tgz#b61a9234ad2f61430937911003cddd7e15c72b45" integrity sha512-eIlgtsmDp1jLC24dRn43hB3kEcZVqx6DUQbR0N1ABXGnMEafm9I3V3dUUeD1vh+Dy5WqijSoEwLNUPLgu5zDMg== -react-native-iphone-x-helper@^1.0.3: +react-native-iphone-x-helper@^1.0.3, react-native-iphone-x-helper@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg== @@ -8139,6 +8168,15 @@ react-native-keyboard-aware-scroll-view@^0.9.5: prop-types "^15.6.2" react-native-iphone-x-helper "^1.0.3" +react-native-paper@^4.12.5: + version "4.12.5" + resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-4.12.5.tgz#5ea4bbe02d416d17802a199de748700358c11d3a" + integrity sha512-gdUtJJf0bw/0xoCE1jR6qCQiQCQZ9ivZh0lbPghFFaGxX88WtTQpusnGON8WhLPeH5odEQ4dTBu99lnIQvSFow== + dependencies: + "@callstack/react-theme-provider" "^3.0.7" + color "^3.1.2" + react-native-iphone-x-helper "^1.3.1" + react-native-safe-area-context@4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.2.4.tgz#4df42819759c4d3c74252c8678c2772cfa2271a6" @@ -8787,6 +8825,13 @@ simple-plist@^1.1.0: bplist-parser "0.3.1" plist "^3.0.5" +simple-swizzle@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" + integrity sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg== + dependencies: + is-arrayish "^0.3.1" + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"