Skip to content

Commit

Permalink
Merge branch 'release-1.0.40' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed Feb 2, 2021
2 parents b068c94 + 1df171d commit e5091f7
Show file tree
Hide file tree
Showing 43 changed files with 2,217 additions and 466 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/developToHeroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy develop branch to foodoasisdev.herokuapp.com

on:
push:
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "foodoasisdev" #Must be unique in Heroku
heroku_email: "[email protected]"
usedocker: true
87 changes: 44 additions & 43 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
# build and push a docker image from the latest push to "develop" branch
on:
push:
branches:
- main
- develop
release:
types:
- published
jobs:
webapi:
runs-on: ubuntu-latest
name: build & push image
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: build-and-push-image
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: foodoasisla/foodoasisla
tag_with_ref: true
tag_with_sha: true
add_git_labels: true
labels: description="Food Oasis LA",maintained="[email protected]"
fullstack:
runs-on: ubuntu-latest
name: build & push image
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: build-and-push-image
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: foodoasisla/foodoasisla
dockerfile: ./Dockerfile-fullstack
tag_with_ref: true
tag_with_sha: true
add_git_labels: true
labels: description="Food Oasis LA",maintained="[email protected]"
# build and push a docker image from the latest push to "develop" branch
on:
push:
branches:
- main
- develop
release:
types:
- published
jobs:
webapi:
runs-on: ubuntu-latest
name: build & push image
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: build-and-push-image
uses: docker/build-push-action@v1
with:
dockerfile: ./Dockerfile-jared
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: foodoasisla/foodoasisla
tag_with_ref: true
tag_with_sha: true
add_git_labels: true
labels: description="Food Oasis LA",maintained="[email protected]"
fullstack:
runs-on: ubuntu-latest
name: build & push image
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: build-and-push-image
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: foodoasisla/foodoasisla
dockerfile: ./Dockerfile
tag_with_ref: true
tag_with_sha: true
add_git_labels: true
labels: description="Food Oasis LA",maintained="[email protected]"
18 changes: 18 additions & 0 deletions .github/workflows/mainToHeroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy main branch to foodoasis.herokuapp.com

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "foodoasis" #Must be unique in Heroku
heroku_email: "[email protected]"
usedocker: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ env
# Just in case developer forgets to rename file to .env
dotenv

# React .env SHOULD be in repo - it has no secrets, and is
# required for GitHub action to build react app.
!/client/.env

/.vscode
.eslintcache

Expand Down
79 changes: 45 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
FROM jred/nodejs:12.17 as builder
LABEL maintainer="[email protected]"
LABEL description="Nodejs docker base image"


FROM node:12.17-buster-slim
LABEL maintainer.fola="[email protected]"
LABEL org.hackforla="Hack For LA"
LABEL description="Food Oasis app"

ENV NODE_ENV "development"

COPY --from=builder /usr/local/bin/ /usr/local/bin/

WORKDIR /fola
COPY package.json ./
COPY package-lock.json ./
RUN npm ci

# TODO @jafow re-structure directory heirarchy so we can flatten these down
COPY middleware/ ./middleware
COPY app/ ./app
COPY server.js ./
COPY db/config.js ./db/
COPY entrypoint.sh ./

# we dont want to run as sudo so create group and user
RUN groupadd -r fola && useradd --no-log-init -r -g fola fola
USER fola

EXPOSE 5000

ENTRYPOINT ["./entrypoint.sh"]
CMD ["node", "server.js"]
FROM node:alpine as clientBuilder

ENV NODE_ENV "development"

RUN mkdir /app
WORKDIR /app
COPY client/package.json .
COPY client/package-lock.json .
RUN npm ci
COPY client .

RUN npm run build
RUN echo package.json

# Server Container
FROM node:12-buster-slim
LABEL maintainer.fola="[email protected]"
LABEL org.hackforla="Hack For LA"
LABEL description="Food Oasis app"

WORKDIR /fola
COPY package.json ./
COPY package-lock.json ./
RUN npm ci

# TODO @jafow re-structure directory heirarchy so we can flatten these down
COPY middleware/ ./middleware
COPY app/ ./app
COPY server.js ./
#COPY db/config.js ./db/
COPY --from=clientBuilder /app/build ./client/build

#COPY entrypoint.sh ./

# we dont want to run as sudo so create group and user
RUN groupadd -r fola && useradd --no-log-init -r -g fola fola
USER fola

EXPOSE 5000

ENTRYPOINT ["/usr/local/bin/node", "server.js"]

# TODO: Make this into a full-stack docker container script
#ENTRYPOINT ["./entrypoint.sh"]
#CMD ["node", "server.js"]
45 changes: 0 additions & 45 deletions Dockerfile-fullstack

This file was deleted.

34 changes: 34 additions & 0 deletions Dockerfile-jared
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM jred/nodejs:12.17 as builder
LABEL maintainer="[email protected]"
LABEL description="Nodejs docker base image"


FROM node:12.17-buster-slim
LABEL maintainer.fola="[email protected]"
LABEL org.hackforla="Hack For LA"
LABEL description="Food Oasis app"

ENV NODE_ENV "development"

COPY --from=builder /usr/local/bin/ /usr/local/bin/

WORKDIR /fola
COPY package.json ./
COPY package-lock.json ./
RUN npm ci

# TODO @jafow re-structure directory heirarchy so we can flatten these down
COPY middleware/ ./middleware
COPY app/ ./app
COPY server.js ./
COPY db/config.js ./db/
COPY entrypoint.sh ./

# we dont want to run as sudo so create group and user
RUN groupadd -r fola && useradd --no-log-init -r -g fola fola
USER fola

EXPOSE 5000

ENTRYPOINT ["./entrypoint.sh"]
CMD ["node", "server.js"]
4 changes: 3 additions & 1 deletion app/controllers/account-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const register = async (req, res) => {

const resendConfirmationEmail = async (req, res) => {
try {
const { email, clientUrl } = req.body;
const response = await accountService.resendConfirmationEmail(
req.body.email
email,
clientUrl
);
res.send(response);
} catch (err) {
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/export-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const downloadFile = (req, res) => {
try {
const file = `${process.cwd()}/uploads/template.csv`;
res.download(file);
} catch (err) {
console.error(err.message);
}
};

module.exports = {
downloadFile,
};
28 changes: 28 additions & 0 deletions app/controllers/import-controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const scraperLaplFoodResourcesService = require("../import/lapl-food-resources-scrape");
const svc = require("../services/load-lapl-food-resources-service");
const importService = require("../services/import-service");

// LA Public Library Food Resources Listing - Scraped
const getLaplFoodResources = async (req, res) => {
Expand All @@ -15,6 +16,33 @@ const getLaplFoodResources = async (req, res) => {
}
};

const uploadStakeholderCsv = async (req, res) => {
const { file } = req;
try {
const response = await importService.parseCsv(file);
res.send(response);
} catch (err) {
console.error(err.message);
}
};

const importStakeholderCsv = async (req, res) => {
const { body } = req;
try {
let response;
if (Array.isArray(body)) {
response = await importService.importCsv(body);
} else {
response = await importService.importCsv([body]);
}
res.send(response);
} catch (err) {
console.error(err.message);
}
};

module.exports = {
getLaplFoodResources,
uploadStakeholderCsv,
importStakeholderCsv,
};
11 changes: 11 additions & 0 deletions app/routes/export-router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const router = require("express").Router();
const jwtSession = require("../../middleware/jwt-session");
const exportController = require("../controllers/export-controller");

router.get(
"/csv-template",
jwtSession.validateUserHasRequiredRoles(["admin"]),
exportController.downloadFile
);

module.exports = router;
Loading

0 comments on commit e5091f7

Please sign in to comment.