Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aguinet committed Sep 6, 2022
0 parents commit e08252f
Show file tree
Hide file tree
Showing 79 changed files with 20,264 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release & publish

on:
release:
types: [created]

jobs:
publish_pip:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
cache-dependency-path: webapp/package-lock.json
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
api/setup.py
cli/setup.py
- name: Install dependencies
run: pip install wheel twine
- name: CLI build
run: cd cli && python ./setup.py bdist_wheel sdist
- name: API build
run: cd api && python ./setup.py bdist_wheel sdist
- name: Webapp wheel build
run: |
cd webapp && npm i
npm run build
python ./setup.py bdist_wheel
- name: Publish to Pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
echo cli/dist/* api/dist/* webapp/dist/*
twine upload cli/dist/* api/dist/* webapp/dist/*
publish_docker:

runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: aguinet/secsend:${{ github.event.release.tag_name }}
file: Dockerfile.prod
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests

on:
push:
branches:
- main
pull_request:

jobs:
tests:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
cache-dependency-path: webapp/package-lock.json
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
api/setup.py
cli/setup.py
- name: CLI tests
run: cd cli && pip install -e .[dev] && cd tests && python -m unittest
- name: API tests
run: cd api && pip install -e .[dev] && cd tests && python -m unittest
- name: Webapp tests
run: cd webapp && npm i && npm run eslint && npm run test
19 changes: 19 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:18-bullseye-slim as builder
RUN apt-get update && DEBIAN_FRONTEND=non-interactive apt-get install -yqq \
python3 python3-pip && \
mkdir /tmp/secsend
COPY ./api /tmp/secsend/api
COPY ./webapp /tmp/secsend/webapp
COPY ./__version__.py /tmp/secsend

RUN cd /tmp/secsend/api && python3 ./setup.py bdist_wheel
RUN cd /tmp/secsend/webapp && npm install && npm run build && python3 ./setup.py bdist_wheel

FROM python:3.10-slim-bullseye

COPY --from=builder /tmp/secsend/api/dist/*.whl /tmp
COPY --from=builder /tmp/secsend/webapp/dist/*.whl /tmp
RUN pip install /tmp/*.whl && rm /tmp/*.whl

ENV SECSEND_BACKEND_FILES_ROOT=/data
ENTRYPOINT /usr/local/bin/sanic secsend_api.prod.app -p ${SECSEND_LISTEN_PORT:-8000} -H 0.0.0.0
Loading

0 comments on commit e08252f

Please sign in to comment.