Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌟feat: internal API proxy #20

Merged
merged 2 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Dockerfile
build

# prevent shipping local development html
public/index-*.html
public/index-*.html

.env*
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ RUN yarn install --prod
COPY . .
RUN NODE_ENV=production yarn build

FROM node:12-alpine
RUN apk update && apk add --no-cache bash git
RUN yarn global add serve
WORKDIR /usr/src/app
FROM nginx:1.18

WORKDIR /usr/share/nginx/html
COPY --from=0 /usr/src/app/build .
COPY --from=0 /usr/src/app/scripts/replaceEnvVars.sh .
EXPOSE 5000

# avoid building everytime
ARG GITHUB_SHA_ARG
ENV GITHUB_SHA=$GITHUB_SHA_ARG
COPY --from=0 /usr/src/app/nginx/nginx.conf /etc/nginx/conf.d/default.conf

CMD ./replaceEnvVars.sh && serve -s .
CMD ./replaceEnvVars.sh && nginx -g 'daemon off;'
18 changes: 18 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {

listen 80;

root /usr/share/nginx/html;
index index.html;

location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://kinto-core:8090;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be an env var?

proxy_set_header Host $host;
}

location /app {
try_files $uri $uri/ /index.html =404;
}

}