mirror of
https://github.com/nodew/haskell-realworld-example.git
synced 2024-08-16 20:20:23 +03:00
Host React SPA with docker
This commit is contained in:
parent
5ca5a13796
commit
f8b9db18ed
@ -1,6 +1,19 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
conduit-www:
|
||||
build:
|
||||
context: ./nginx
|
||||
args:
|
||||
- UPSTREAM=http://conduit-server:8080/api
|
||||
depends_on:
|
||||
- conduit-server
|
||||
ports:
|
||||
- "8000:80"
|
||||
restart: on-failure
|
||||
networks:
|
||||
- intranet
|
||||
|
||||
conduit-server:
|
||||
build: .
|
||||
depends_on:
|
||||
|
26
nginx/Dockerfile
Normal file
26
nginx/Dockerfile
Normal file
@ -0,0 +1,26 @@
|
||||
FROM node:lts-slim as builder
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update
|
||||
|
||||
RUN apt install git -y
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN git clone --depth=1 https://github.com/khaledosman/react-redux-realworld-example-app.git .
|
||||
RUN sed -i "s#https://conduit.productionready.io/api#/api#" ./src/agent.js
|
||||
|
||||
RUN yarn install
|
||||
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx:1.21.6-alpine
|
||||
|
||||
ARG UPSTREAM="http://localhost:8080"
|
||||
|
||||
COPY --from=builder /app/build /srv
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
RUN sed -i "s#<upstream>#$UPSTREAM#" /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
14
nginx/nginx.conf
Normal file
14
nginx/nginx.conf
Normal file
@ -0,0 +1,14 @@
|
||||
server{
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
root /srv;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass <upstream>;
|
||||
}
|
||||
}
|
@ -16,7 +16,10 @@ import Conduit.Db
|
||||
import Conduit.App
|
||||
|
||||
newtype TagsResponse = TagsResponse
|
||||
{ tags :: [Text] } deriving (Generic, ToJSON)
|
||||
{ tags :: [Text] } deriving (Generic)
|
||||
|
||||
instance ToJSON TagsResponse where
|
||||
toJSON (TagsResponse a) = object ["tags" .= a]
|
||||
|
||||
type TagApi = "tags" :> Get '[JSON] TagsResponse
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user