前端容器启动时执行命令 电脑版发表于:2022/12/24 21:24 tn>dockerfile ```bash FROM nginx RUN rm /etc/nginx/conf.d/default.conf ADD ./default.conf /etc/nginx/conf.d COPY ./certs/ /etc/nginx/cert/ COPY ./dist/ /usr/share/nginx/html/ COPY ./container-start.sh /00-container-start.sh RUN chmod +x 00-container-start.sh RUN cp /00-container-start.sh /docker-entrypoint.d/ ``` tn2>container-start.sh ```bash #!/bin/bash echo $BACK_API_URL echo $BACK_IDENTITY_URL # export BACK_API_URL="https://bob:5000" # export BACK_IDENTITY_URL="https://bob:7200" for f in `ls /usr/share/nginx/html/js/ | grep app` do echo $f filepath=/usr/share/nginx/html/js/$f filemappath=/usr/share/nginx/html/js/$f sed -i 's#'https://localhost:5000'#'$BACK_API_URL'#g' $filepath sed -i 's#'https://localhost:7200'#'$BACK_IDENTITY_URL'#g' $filemappath done echo "finish!!!" ```