diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4a3390c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +logs +*.log +npm-debug.log* +.DS_Store + +coverage +node_modules +build +.env.local +.env.development.local +.env.test.local +.env.production.local + +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c46370 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM node:10-alpine3.11 AS base + +WORKDIR /app + +# I dont know why, but when doing npm install in this Dockerfile, methone just gets cloned but there +# is no dist directory, which makes the build fail since there is nothing in methone to import. +# Also: cd:ing into node_modules/methone and running `npm i && npm run build` doesn't. +FROM base as methone-builder + +RUN apk add git +RUN git clone https://github.com/datasektionen/methone . +RUN npm i +RUN npm run build + +FROM base as builder + +RUN apk add git +COPY package.json package-lock.json ./ +RUN npm i +COPY --from=methone-builder /app/dist ./node_modules/methone/dist + +COPY bin bin +COPY public public +COPY src src +COPY razzle.config.js . + +ENV NODE_ENV=production +ARG RAZZLE_TAITAN_URL +ARG RAZZLE_CALYPSO_URL + +RUN npm run build + +FROM base + +COPY --from=builder /app/package.json /app/package-lock.json ./ +COPY --from=builder /app/node_modules node_modules +COPY --from=builder /app/build build + +CMD ["npm", "start"] diff --git a/README.md b/README.md index 42b3a85..99b4502 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,19 @@ -BAWANG -====== +# BAWANG Universal react application for the chapter website. -Running -------- -Bawang runs on Node v.10.x.x. It doesn't work on later versions (v.12.20.1) - -`npm start:dev` will start the whole universal server in development mode. HMR will be enabled on both server and client side! +## Environment variables -`npm run build` will build a production ready server. +| Name | Default | Description | +|--------------------|--------------------------------------|-----------------------------------------------------------------------------------------------------| +| TAITAN_URL | https://taitan.datasektionen.se | URL to get contents from taitan on | +| RAZZLE_TAITAN_URL | https://taitan.datasektionen.se | URL to get contents from taitan on. **Set during build**. Should probably be the same as TAITAN_URL | +| RAZZLE_CALYPSO_URL | https://calypso.datasektionen.se/api | URL to get news from calypso on. **Set during build** | +| PORT | 3000 | Port to listen on | -`npm run start` will start the production server. +## Running +Bawang runs on Node v.10.x.x. It doesn't work on later versions (v.12.20.1) -TODO ----- -- Fix frontpage styling -- Feature complete news page -- Improve translation implementation -- Add more content providers, i.e. skywhale, pandora -- Write a more helpful README +- `npm start:dev` will start the whole universal server in development mode. HMR will be enabled on both server and client side! +- `npm run build` will build a production ready server. +- `npm start` will start the production server.