Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
828b600
Implement serving app's static files from middleware server;
ScriptyChris Mar 1, 2021
40c08d6
Fix app serving behavior consistency between backend development and …
ScriptyChris Mar 2, 2021
d0c1531
Remove prebuild npm scripts;
ScriptyChris Mar 4, 2021
ff1a32b
Add GitHub workflow YML file;
ScriptyChris Mar 4, 2021
98f1c59
[debugging] check env variables on GitHub workflow;
ScriptyChris Mar 4, 2021
8fea0ab
[debugging] change 'set' to 'export' keyword to setup ENV variables f…
ScriptyChris Mar 4, 2021
4dd6db6
[debugging] check test/ to src/ module paths mapping in GitHub workflow;
ScriptyChris Mar 4, 2021
069de78
[debugging] fix module mapper path separator depent on OS;
ScriptyChris Mar 4, 2021
e5f1858
Add dotenv package to manage ENV variables;
ScriptyChris Mar 19, 2021
95bb5ef
Add cross-env package to unify setting ENV variables in CLI per OS; A…
ScriptyChris Mar 23, 2021
825782e
Extend CI/CD workflow to create and publish Docker image for production;
ScriptyChris Mar 31, 2021
74ffa32
Fix eslint:test npm script; Remove app build step from CI workflow;
ScriptyChris Mar 31, 2021
31be1e1
Fix build-docker-image.yml indentation;
ScriptyChris Mar 31, 2021
fc14aad
[WIP] temporarily run building production docker image on PR check flow;
ScriptyChris Mar 31, 2021
4e654b3
[WIP] fix GITHUB_ENV variable creation;
ScriptyChris Mar 31, 2021
2e836a1
[WIP] move tag url prefix to REPO_LOWERCASE variable;
ScriptyChris Mar 31, 2021
480496d
[WIP] fix reading env variable;
ScriptyChris Mar 31, 2021
63bb7a3
[WIP] remove installing and building app steps from CD workflow and a…
ScriptyChris Mar 31, 2021
f6b8031
[WIP] remove incorrect registry prop key from workflow step and list …
ScriptyChris Mar 31, 2021
0869d99
[WIP] copy project's necessary source files to build docker image;
ScriptyChris Mar 31, 2021
ef84802
[WIP] use docker RUN command in shell form to output folder content b…
ScriptyChris Mar 31, 2021
2caf428
[WIP] fix building docker image; Add docker-compose to link MongoDB w…
ScriptyChris Apr 1, 2021
6a6494b
Fix populating database with products;
ScriptyChris Apr 9, 2021
0e11700
Remove step of copying unavailable /dist folder while building docker…
ScriptyChris Apr 9, 2021
9c1c144
Fix lowercasing repository name from variable in GitHub Action;
ScriptyChris Apr 9, 2021
e45e822
Another fix of gh repository variable;
ScriptyChris Apr 9, 2021
bf4a177
Check whether hardcoded repository URL is ok for GH action;
ScriptyChris Apr 9, 2021
1c31833
Try setting docker image build tag explicitly;
ScriptyChris Apr 9, 2021
4f900b6
Add tmate GH action to debug 403 error;
ScriptyChris Apr 10, 2021
73f12c2
Recover setting REPO_LOWERCASE variable from GH env var and move run…
ScriptyChris Apr 10, 2021
9d81a5c
Try another GH env resolving way;
ScriptyChris Apr 10, 2021
e235460
Try to manually push docker image to registry;
ScriptyChris Apr 12, 2021
133e795
Explicitly add tag to docker image while building it;
ScriptyChris Apr 12, 2021
628a0c4
Exclude registry and repo names from tag;
ScriptyChris Apr 12, 2021
225f916
Verbosely tag image before pushing it to registry;
ScriptyChris Apr 12, 2021
00b61fc
Move debugging before manual pushing docker image;
ScriptyChris Apr 12, 2021
d18e4fe
Try building image on local GH action vm;
ScriptyChris Apr 12, 2021
519e025
Set explicit path for local docker image built;
ScriptyChris Apr 12, 2021
661a5e8
Switch building app's docker image on PR to just run unit tests; Buil…
ScriptyChris Apr 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL=mongodb://mongo:27017/pev_shop
SECRET_KEY=secret-key
PORT=3000
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: refactor to use ENV
const isBackendOnly = process.env.BACKEND_ONLY === 'true';
const isTestEnv = process.env.TEST_ENV === 'true';

Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build production Docker image

on:
#push:
#branches: [ develop ]
pull_request:
branches: [ empty ]

jobs:
build-docker-image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1

- name: Login to Docker registry on GitHub
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Lowercase author and repository name
#run: echo "REPO_LOWERCASE=ghcr.io/scriptychris/fake-pev-shopping" >> $GITHUB_ENV
run: echo "REPO_LOWERCASE=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v2
with:
# push: true
outputs: type=local,dest=./built-docker-image
tags: ghcr.io/scriptychris/fake-pev-shopping:latest #${{ env.REPO_LOWERCASE }}

# for debugging purposes
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Manually push docker image to registry
run: >
docker tag fake-pev-shopping ghcr.io/scriptychris/fake-pev-shopping:latest &&
docker push ghcr.io/scriptychris/fake-pev-shopping:latest
18 changes: 18 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Integrate

on:
pull_request:
branches: [ develop ]

jobs:
run-unit-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.15.5

- run: npm ci
- run: npm test
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:lts-alpine3.13

WORKDIR /app

COPY ./package*.json ./
RUN npm ci

COPY ./src ./src
COPY ./utils ./utils
COPY .env .babelrc tsconfig* webpack.config.js ./
RUN npm run build

# TODO: automate database population process on Docker image build.
# Need to handle race condition between starting MongoDB.
#WORKDIR /app/dist/src/database/populate
#RUN node populate.js --categoriesGroupPath=categoryGroups.json trialProducts.json

EXPOSE 3000

CMD ["npm", "run", "serve"]
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3"

services:
mongo:
image: mongo:4.2.13-bionic
ports:
- 27017:27017

node:
build: ./
image: fake-pev-shopping
ports:
- 3000:3000
depends_on:
- mongo
18 changes: 0 additions & 18 deletions index.html

This file was deleted.

Loading