Skip to content

Commit

Permalink
online-sitemap-builder: Fix nginx and deployment settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jan 14, 2023
1 parent 7a6adde commit 33b3913
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/online-sitemap-builder.yml
Expand Up @@ -66,7 +66,7 @@ jobs:
region=${{ secrets.ONLINE_SITEMAP_BUILDER_GCP_REGION }}
gcloud auth configure-docker ${region}-docker.pkg.dev
- run: |-
docker build -t ${IMAGE_URL} .
docker build --build-arg BASE_PATH=/lab/online-sitemap-builder -t ${IMAGE_URL} .
docker push ${IMAGE_URL}
- run: |-
gcloud run deploy ${{ secrets.ONLINE_SITEMAP_BUILDER_GCP_SERVICE }} \
Expand All @@ -77,5 +77,4 @@ jobs:
--platform "managed" \
--quiet \
--region ${{ secrets.ONLINE_SITEMAP_BUILDER_GCP_REGION }} \
--service-account ${{ secrets.ONLINE_SITEMAP_BUILDER_GCP_SERVICE_ACCOUNT }} \
--set-env-vars "BASE_PATH=/lab/online-sitemap-builder"
--service-account ${{ secrets.ONLINE_SITEMAP_BUILDER_GCP_SERVICE_ACCOUNT }}
9 changes: 5 additions & 4 deletions online-sitemap-builder/Dockerfile
Expand Up @@ -3,14 +3,15 @@ WORKDIR /home/rust
RUN cargo install --locked trunk
RUN rustup target add wasm32-unknown-unknown
COPY . .
RUN trunk build
ARG BASE_PATH=/
RUN cat /home/rust/nginx.conf | sed "s#\$BASE_PATH#${BASE_PATH}#" > /home/rust/nginx-build-path.conf
RUN trunk build --public-url "${BASE_PATH}"

FROM nginx:1.23.3
COPY nginx.conf /etc/nginx/conf.d/configfile.template
COPY --from=builder /home/rust/nginx-build-path.conf /etc/nginx/conf.d/configfile.template
COPY --from=builder /home/rust/dist /usr/share/nginx/html
ENV BASE_PATH /
ENV PORT 8080
ENV HOST 0.0.0.0
EXPOSE 8080
CMD sh -c "cat /etc/nginx/conf.d/configfile.template | envsubst '\$PORT' | envsubst '\$BASE_PATH' > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
CMD sh -c "cat /etc/nginx/conf.d/configfile.template | envsubst '\$PORT' > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

4 changes: 3 additions & 1 deletion online-sitemap-builder/nginx.conf
Expand Up @@ -2,10 +2,12 @@ server {
listen $PORT;
server_name localhost;
root /usr/share/nginx/html;
absolute_redirect off;

location $BASE_PATH {
alias /usr/share/nginx/html;
index index.html
index index.html;
rewrite ^(.+)/$ $1 permanent;
try_files $uri /index.html;
}

Expand Down

0 comments on commit 33b3913

Please sign in to comment.