diff --git a/docker-compose.yml b/docker-compose.yml index 7543bbe..767534a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..0773324 --- /dev/null +++ b/nginx/Dockerfile @@ -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#" /etc/nginx/conf.d/default.conf + +EXPOSE 80 diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..c839df8 --- /dev/null +++ b/nginx/nginx.conf @@ -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 ; + } +} diff --git a/src/Conduit/Api/Tag.hs b/src/Conduit/Api/Tag.hs index af7867e..8da0064 100644 --- a/src/Conduit/Api/Tag.hs +++ b/src/Conduit/Api/Tag.hs @@ -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