react native - การกระทำของ Github ล้มเหลวในการสร้าง Typescript แต่บนเครื่องท้องถิ่นทำงานได้
ฉันกำลังใช้ Github Actions เพื่อสร้างและส่ง Docker container ไปยัง Azure Repository ภายในแอปพลิเคชัน react-native-web สิ่งที่แปลกคือในเครื่อง Windows 10 ส่วนตัวของฉัน กระบวนการ build ของแอป React Web สามารถทำงานได้ แต่ใน Github Action ไม่สามารถทำงานได้ มันแจ้งข้อผิดพลาดเกี่ยวกับ Typescript (แอปพลิเคชันถูกเขียนใน TS) เพราะกระบวนการ build ถูกดำเนินการในเครื่อง Ubuntu ที่ถูก Dockerized เหมือนกัน ฉันคิดว่าผลลัพธ์ควรจะเหมือนกันเสมอ แต่กลับไม่เป็นแบบนั้น
นี่คือแอ็กชัน Github ของฉัน
This is a basic workflow to help you get started with Actions
name: Publish Web Client prod
Controls when the action will run. Triggers the workflow on push or pull request
events but only for the master branch
on:
push:
branches: publish-web-prod
A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2
# allow to login to azure registry container
- name: Login to Azure
uses: azure/docker-login@v1
with:
login-server: registryviatek.azurecr.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Runs a set of commands using the runners shell
- name: Run build and publish web prod
run: |
docker build -f ${{ github.workspace }}/src/app/DockerfileGithubProd -t registry.azurecr.io/frontendweb-prod:${{ github.sha }} --no-cache .
docker push registry.azurecr.io/frontendweb-prod:${{ github.sha }}
นี่คือไฟล์ Docker ของฉัน:
build environment
FROM node:14.15.5-alpine as build
RUN apk update
RUN apk add git
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY src/app/package.json /app/package.json
RUN npm install --silent
RUN npm install [email -g --silent
COPY src/app /app
RUN npm run build
production environment
FROM nginx:1.17.4-alpine
COPY --from=build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY src/app/nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
และนี่คือล็อกผลลัพธ์จาก Github:
Run docker build -f /home/runner/work/App/App/src/app/DockerfileGithubTest -t ***.azurecr.io/frontendweb-test:df0a8964152d2bf50917e59de0af1d2a93e88783 --no-cache .
docker build -f /home/runner/work/App/App/src/app/DockerfileGithubTest -t ***.azurecr.io/frontendweb-test:df0a8964152d2bf50917e59de0af1d2a93e88783 --no-cache .
docker push ***.azurecr.io/frontendweb-test:df0a8964152d2bf50917e59de0af1d2a93e88783
shell: /usr/bin/bash -e {0}
env:
DOCKER_CONFIG: /home/runner/work/_temp/docker_login_1617897140374
Sending build context to Docker daemon 15.17MB
Step 1/16 : FROM node:14.15.5-alpine as build
14.15.5-alpine: Pulling from library/node
0a6724ff3fcd: Pulling fs layer
3b3c21ce1f8c: Pulling fs layer
560ed84bbbcc: Pulling fs layer
281a19a6c438: Pulling fs layer
281a19a6c438: Waiting
0a6724ff3fcd: Verifying Checksum
0a6724ff3fcd: Download complete
281a19a6c438: Verifying Checksum
281a19a6c438: Download complete
0a6724ff3fcd: Pull complete
3b3c21ce1f8c: Verifying Checksum
3b3c21ce1f8c: Download complete
560ed84bbbcc: Verifying Checksum
560ed84bbbcc: Download complete
3b3c21ce1f8c: Pull complete
560ed84bbbcc: Pull complete
281a19a6c438: Pull complete
Digest: sha256:5edad160011cc8cfb69d990e9ae1cb2681c0f280178241d58eba05b5bfc34047
Status: Downloaded newer image for node:14.15.5-alpine
---> c1babb15a629
Step 2/16 : RUN apk update
---> Running in 25acb5a203e5
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.10-8-gf8ac3999ba [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.10-2-gc655f5d2f5 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11278 distinct packages available
Removing intermediate container 25acb5a203e5
---> 63fdb83b1dfd
Step 3/16 : RUN apk add git
---> Running in 2a8874928a55
(1/6) Installing ca-certificates (20191127-r2)
(2/6) Installing nghttp2-libs (1.40.0-r1)
(3/6) Installing libcurl (7.67.0-r3)
(4/6) Installing expat (2.2.9-r1)
(5/6) Installing pcre2 (10.34-r1)
(6/6) Installing git (2.24.4-r0)
Executing busybox-1.31.1-r9.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 23 MiB in 22 packages
Removing intermediate container 2a8874928a55
---> 5bc04a41d9c2
Step 4/16 : WORKDIR /app
---> Running in d5c9efa1b69a
Removing intermediate container d5c9efa1b69a
---> 5dbe08ad7bbd
Step 5/16 : ENV PATH /app/node_modules/.bin:$PATH
---> Running in e9066449d147
Removing intermediate container e9066449d147
---> 65f6dbf0d570
Step 6/16 : COPY src/app/package.json /app/package.json
---> 073aeb43cf5c
Step 7/16 : RUN npm install --silent
---> Running in 0ef783dd1abb
Download the file
Download completed!
Extract content
Extract complete!
Delete the downloaded file
added 2188 packages from 1166 contributors and audited 2198 packages in 74.182s
100 packages are looking for funding
run `npm fund` for details
found 9 vulnerabilities (6 low, 3 high)
run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container 0ef783dd1abb
---> b1fbb2e35ceb
Step 8/16 : RUN npm install [email -g --silent
---> Running in 8d1c76d8f6ab
/usr/local/bin/react-scripts -> /usr/local/lib/node_modules/react-scripts/bin/react-scripts.js
+ [email
added 1618 packages from 748 contributors in 43.313s
Removing intermediate container 8d1c76d8f6ab
---> eac5ceccd774
Step 9/16 : COPY src/app /app
---> 5bc1cff62d99
Step 10/16 : RUN npm run build:test
---> Running in 141e7cf15400
> [email build:test /app
> env-cmd -f .env.staging react-app-rewired build
Creating an optimized production build...
Failed to compile.
/app/src/features/login/login-form/index.tsx
TypeScript error in /app/src/features/login/login-form/index.tsx(38,8):
Type '{ style: { backgroundColor: string; }; icon: string; size: number; color: string; }' is missing the following properties from type 'Pick<Props, "ref" | "style" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | ... 48 more ... | "icon">': accessibilityComponentType, accessibilityTraits TS2739
36 | <Image source={require('../../../images/header.png')} resizeMode="center"></Image>
37 |
> 38 | <Avatar.Icon style={styles.avatarLockIcon} icon="lock" size={40} color="white"></Avatar.Icon>
| ^
39 | <ViaText type="title" text="Accedi" style={styles.avatarLocktxt}></ViaText>
40 | </View>
41 |
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email build:test: `env-cmd -f .env.staging react-app-rewired build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email build:test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-04-08T15_56_54_595Z-debug.log
The command '/bin/sh -c npm run build:test' returned a non-zero code: 1
Error: Process completed with exit code 1.
ฉันรู้ว่าเกิดข้อผิดพลาดนี้ขึ้นดูเหมือนถูกต้องที่จะเกิดขึ้น แต่ถ้าฉันรัน npm run build หรือสร้างคอนเทนเนอร์บนเครื่องของฉัน พวกมันจะทำงานได้