Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 0 additions & 63 deletions .circleci/config.aws.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: ci

on:
pull_request:
branches: [main, master]

permissions:
contents: write
pull-requests: write
Comment on lines +8 to +9

jobs:
build-test:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'duluca'
strategy:
fail-fast: false
matrix:
include:
- subdir: server
image: minimal-mean-server
node: '12'
container_port: 3000
expected: "Server is up and running"
needs_mongo: 'true'
- subdir: web-app
image: minimal-mean-web-app
node: '12'
container_port: 80
expected: "Minimal MEAN Web App"
needs_mongo: 'false'
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: npm install
working-directory: ${{ matrix.subdir }}
run: npm install --legacy-peer-deps --no-audit --no-fund

- name: npm run build
working-directory: ${{ matrix.subdir }}
run: npm run build

- name: Build image
working-directory: ${{ matrix.subdir }}
run: docker build -t local-test:${{ github.sha }} .

- name: Start mongo sidecar
if: matrix.needs_mongo == 'true'
run: |
docker network create testnet
docker run -d --name testmongo --network testnet mongo:5
sleep 3

- name: Smoke test - container starts and stays up
run: |
extra=""
if [ "${{ matrix.needs_mongo }}" = "true" ]; then
extra="--network testnet -e MONGO_URI=mongodb://testmongo:27017/test"
fi
docker run -d --name testc $extra -p 8080:${{ matrix.container_port }} local-test:${{ github.sha }}
sleep 5
docker ps --filter "name=testc" --filter "status=running" --format '{{.Names}}' | grep -q testc \
|| (echo "container exited"; docker logs testc; exit 1)

- name: Endpoint check
run: |
for i in 1 2 3 4 5 6 7 8 9 10; do
if curl -fsS http://localhost:8080/ -o /tmp/body; then break; fi
sleep 2
done
grep -qi "${{ matrix.expected }}" /tmp/body \
|| (echo "expected content missing. Container logs:"; docker logs testc; echo "Response body:"; cat /tmp/body 2>/dev/null || echo "(no body)"; exit 1)

- name: Cleanup
if: always()
run: |
docker rm -f testc 2>/dev/null || true
docker rm -f testmongo 2>/dev/null || true
docker network rm testnet 2>/dev/null || true

auto-merge:
needs: build-test
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'duluca'
steps:
- name: Auto-merge PR
env:
GH_TOKEN: ${{ secrets.AUTOMERGE_PAT }}
run: gh pr merge ${{ github.event.pull_request.number }} --squash --delete-branch --admin -R ${{ github.repository }}
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: publish

on:
push:
branches: [main, master]

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- subdir: server
image: minimal-mean-server
node: '12'
- subdir: web-app
image: minimal-mean-web-app
node: '12'
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: npm install
working-directory: ${{ matrix.subdir }}
run: npm install --legacy-peer-deps --no-audit --no-fund

- name: npm run build
working-directory: ${{ matrix.subdir }}
run: npm run build
Comment on lines +34 to +36

- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
working-directory: ${{ matrix.subdir }}
run: |
docker build \
-t expertlysimple/${{ matrix.image }}:latest \
-t expertlysimple/${{ matrix.image }}:${{ github.sha }} \
.
docker push expertlysimple/${{ matrix.image }}:latest
docker push expertlysimple/${{ matrix.image }}:${{ github.sha }}
8 changes: 4 additions & 4 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:lts-alpine

RUN apk add --update --no-progress make python bash
RUN apk add --update --no-progress make python3 bash
ENV NPM_CONFIG_LOGLEVEL error

ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 /usr/local/bin/dumb-init
Expand All @@ -13,8 +13,8 @@ USER node

WORKDIR /usr/src/app

ADD package.json .
ADD package-lock.json .
ADD --chown=node:node package.json .
ADD --chown=node:node package-lock.json .
RUN NODE_ENV=production

RUN npm install --only=production
Expand All @@ -23,7 +23,7 @@ ENV HOST "0.0.0.0"
ENV PORT 3000
EXPOSE 3000

ADD dist dist
ADD --chown=node:node dist dist

ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "dist/index"]
Loading