-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from wearefuturegov/develop
Staging update
- Loading branch information
Showing
50 changed files
with
5,278 additions
and
2,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: "3.7" | ||
services: | ||
mongo: | ||
image: mongo:6 | ||
ports: | ||
- 27018:27017 | ||
volumes: | ||
- mongo-volume:/data/db | ||
- ./setup-mongodb.js:/docker-entrypoint-initdb.d/mongo-init.js:ro | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME:-admin} | ||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:-password} | ||
MONGO_INITDB_USERNAME: ${MONGO_INITDB_USERNAME:-outpost} | ||
MONGO_INITDB_PASSWORD: ${MONGO_INITDB_PASSWORD:-password} | ||
MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE:-outpost_api_development} | ||
networks: | ||
- internal_network | ||
|
||
volumes: | ||
mongo-volume: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
db = db.getSiblingDB( | ||
process.env.MONGO_INITDB_DATABASE || "outpost_api_development" | ||
) | ||
|
||
db.createUser({ | ||
user: process.env.MONGO_INITDB_USERNAME || "outpost", | ||
pwd: process.env.MONGO_INITDB_PASSWORD || "password", | ||
roles: [ | ||
{ | ||
role: "readWrite", | ||
db: process.env.MONGO_INITDB_DATABASE || "outpost_api_development", | ||
}, | ||
], | ||
}) | ||
|
||
db.createCollection("indexed_services") | ||
|
||
db.indexed_services.createIndex( | ||
{ | ||
name: "text", | ||
description: "text", | ||
}, | ||
{ | ||
weights: { | ||
name: 5, | ||
description: 1, | ||
}, | ||
} | ||
) | ||
db.indexed_services.createIndex({ | ||
"locations.geometry": "2dsphere", | ||
}) | ||
db.indexed_services.createIndex({ | ||
"taxonomies.slug": 1, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# git | ||
.git | ||
.gitattributes | ||
.gitignore | ||
.github | ||
|
||
# env | ||
.env | ||
.env.* | ||
|
||
# node | ||
node_modules | ||
|
||
# misc | ||
.DS_Store | ||
*.swp | ||
*~ | ||
|
||
# logs | ||
log/* | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.yarn-integrity | ||
|
||
# Added in case image is built locally without fresh checkout | ||
.idea | ||
.vscode | ||
.ruby-lsp | ||
coverage | ||
|
||
# heroku | ||
Procfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This action pre-builds the dev-base image and pushes it to the GitHub Container Registry (GHCR) | ||
|
||
name: Deploy outpost api image to github container registry | ||
|
||
on: | ||
push: | ||
branches: [develop, staging, production] | ||
|
||
jobs: | ||
push-outpost-api-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout GitHub Action" | ||
uses: actions/checkout@main | ||
|
||
- name: "Login to GitHub Container Registry" | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Set Docker Image Tag | ||
id: vars | ||
run: | | ||
BRANCH_NAME=${GITHUB_REF#refs/heads/} | ||
if [[ "$BRANCH_NAME" == "develop" ]]; then | ||
echo "::set-output name=tag::development" | ||
elif [[ "$BRANCH_NAME" == "staging" ]]; then | ||
echo "::set-output name=tag::staging" | ||
elif [[ "$BRANCH_NAME" == "production" ]]; then | ||
echo "::set-output name=tag::latest" | ||
fi | ||
- name: Build and push outpost api docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
tags: ghcr.io/wearefuturegov/outpost-api-service:${{ steps.vars.outputs.tag }} | ||
file: Dockerfile.production | ||
platforms: ${{ matrix.platforms }} | ||
push: true | ||
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Outpost API Service image | ||
labels: org.opencontainers.image.source=https://github.com/wearefuturegov/outpost-api-service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Run tests | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/Iron | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: npm run test | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: wearefuturegov/outpost-api-service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
node_modules | ||
.env | ||
.vscode | ||
/environment/artifacts | ||
.DS_Store | ||
coverage | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v16.18.0 | ||
lts/Iron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["actboy168.tasks"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"workbench.colorCustomizations": { | ||
"activityBar.background": "#4F1C28", | ||
"titleBar.activeBackground": "#6F2739", | ||
"titleBar.activeForeground": "#FEFCFC" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Build", | ||
"type": "shell", | ||
"command": "cd ${workspaceRoot} && make build", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"options": { | ||
"statusbar": { | ||
"label": "Build environment" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Start environment", | ||
"type": "shell", | ||
"command": "cd ${workspaceRoot} && make start", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"options": { | ||
"statusbar": { | ||
"label": "Start environment" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Open shell", | ||
"type": "shell", | ||
"command": "cd ${workspaceRoot} && make shell", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"options": { | ||
"statusbar": { | ||
"label": "Open shell" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Stop environment", | ||
"type": "shell", | ||
"command": "cd ${workspaceRoot} && make stop", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"options": { | ||
"statusbar": { | ||
"label": "Stop environment" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
ARG NODE_ENV=development | ||
|
||
# ---------------------------------------------------------------- | ||
FROM node:iron-alpine as build_frontend | ||
ARG NODE_ENV | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
COPY ./package.json ./tmp/package.json | ||
COPY ./package-lock.json ./tmp/package-lock.json | ||
|
||
WORKDIR /tmp | ||
|
||
RUN if [ "${NODE_ENV}" = "development" ] || [ -z "${NODE_ENV}" ]; then \ | ||
npm install; fi | ||
RUN if [ "${NODE_ENV}" = "production" ]; then \ | ||
npm ci && npm cache clean --force; fi | ||
|
||
WORKDIR /app | ||
|
||
# ---------------------------------------------------------------- | ||
FROM build_frontend | ||
ARG NODE_ENV | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
COPY --from=build_frontend /tmp/package.json ./package.json | ||
COPY --from=build_frontend /tmp/package-lock.json ./package-lock.json | ||
COPY --from=build_frontend /tmp/node_modules ./node_modules | ||
|
||
|
||
EXPOSE 3000 | ||
ENTRYPOINT ["npm", "run"] | ||
CMD ["dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ARG NODE_ENV=production | ||
ARG FORCE_SSL=true | ||
|
||
# ---------------------------------------------------------------- | ||
FROM node:iron-alpine as build_frontend | ||
ARG NODE_ENV | ||
ARG FORCE_SSL | ||
ENV NODE_ENV $NODE_ENV | ||
RUN adduser -D outpost-user | ||
|
||
COPY ./package.json ./tmp/package.json | ||
COPY ./package-lock.json ./tmp/package-lock.json | ||
|
||
WORKDIR /tmp | ||
|
||
RUN if [ "${NODE_ENV}" = "development" ] || [ -z "${NODE_ENV}" ]; then \ | ||
npm install; fi | ||
RUN if [ "${NODE_ENV}" = "production" ]; then \ | ||
npm ci --omit=dev && npm cache clean --force; fi | ||
|
||
WORKDIR /app | ||
|
||
# ---------------------------------------------------------------- | ||
FROM build_frontend | ||
ARG NODE_ENV | ||
ARG FORCE_SSL | ||
ENV NODE_ENV $NODE_ENV | ||
ENV FORCE_SSL $FORCE_SSL | ||
|
||
COPY --from=build_frontend --chown=outpost-user:outpost-user /tmp/node_modules /app/node_modules | ||
COPY . /app | ||
|
||
USER outpost-user | ||
EXPOSE 3000 | ||
ENTRYPOINT ["npm", "run"] | ||
CMD ["start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# TODO | ||
|
||
- [x] Automate tests with docker and github actions | ||
- [ ] Automatic linter on commit and PR's | ||
- [x] An option to push some dummy data to the API | ||
- [ ] Add support for csv export https://developers.openreferraluk.org/API-Guidance/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"results": [ | ||
{ | ||
"address_components": [ | ||
{ | ||
"long_name": "London", | ||
"short_name": "London", | ||
"types": ["locality", "political"] | ||
}, | ||
{ | ||
"long_name": "London", | ||
"short_name": "London", | ||
"types": ["postal_town"] | ||
}, | ||
{ | ||
"long_name": "Greater London", | ||
"short_name": "Greater London", | ||
"types": ["administrative_area_level_2", "political"] | ||
}, | ||
{ | ||
"long_name": "England", | ||
"short_name": "England", | ||
"types": ["administrative_area_level_1", "political"] | ||
}, | ||
{ | ||
"long_name": "United Kingdom", | ||
"short_name": "GB", | ||
"types": ["country", "political"] | ||
} | ||
], | ||
"formatted_address": "London, UK", | ||
"geometry": { | ||
"bounds": { | ||
"northeast": { | ||
"lat": 51.6723432, | ||
"lng": 0.148271 | ||
}, | ||
"southwest": { | ||
"lat": 51.38494009999999, | ||
"lng": -0.3514683 | ||
} | ||
}, | ||
"location": { | ||
"lat": 51.5072178, | ||
"lng": -0.1275862 | ||
}, | ||
"location_type": "APPROXIMATE", | ||
"viewport": { | ||
"northeast": { | ||
"lat": 51.6723432, | ||
"lng": 0.148271 | ||
}, | ||
"southwest": { | ||
"lat": 51.38494009999999, | ||
"lng": -0.3514683 | ||
} | ||
} | ||
}, | ||
"place_id": "ChIJdd4hrwug2EcRmSrV3Vo6llI", | ||
"types": ["locality", "political"] | ||
} | ||
], | ||
"status": "OK" | ||
} |
Oops, something went wrong.