Skip to content

Commit 911c083

Browse files
authored
Merge pull request #10 from jtdub/docker
Add Docker Build
2 parents 6921a1d + b612c47 commit 911c083

File tree

3 files changed

+85
-21
lines changed

3 files changed

+85
-21
lines changed

.github/workflows/linting.yaml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Linting
1+
name: "Linting"
22

33
on:
44
push:
@@ -7,26 +7,61 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
build:
11-
10+
hadolint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: hadolint/[email protected]
15+
with:
16+
dockerfile: Dockerfile
17+
black:
1218
runs-on: ubuntu-latest
1319
strategy:
1420
fail-fast: true
1521
matrix:
16-
python-version: [3.8, 3.9]
17-
22+
python-version: [3.9]
1823
steps:
1924
- uses: actions/checkout@v2
2025
- name: Set up Python ${{ matrix.python-version }}
2126
uses: actions/setup-python@v2
2227
with:
2328
python-version: ${{ matrix.python-version }}
24-
- name: Install Poetry, Install Dependencies, and Execute Linters
29+
- name: "Setup environment"
30+
uses: "networktocode/gh-action-setup-poetry-environment@v2"
31+
- name: "Linting: Black"
2532
run: |
26-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
27-
source $HOME/.poetry/env
28-
poetry install
2933
poetry run black --diff netopsio/
34+
pylint:
35+
runs-on: ubuntu-latest
36+
strategy:
37+
fail-fast: true
38+
matrix:
39+
python-version: [3.9]
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
- name: "Setup environment"
47+
uses: "networktocode/gh-action-setup-poetry-environment@v2"
48+
- name: "Linting: PyLint"
49+
run: |
3050
poetry run pylint netopsio/netopsio/ netopsio/home/
31-
poetry run flake8 netopsio/ --ignore E501
32-
# poetry run bandit -r netopsio/
51+
flake8:
52+
runs-on: ubuntu-latest
53+
strategy:
54+
fail-fast: true
55+
matrix:
56+
python-version: [3.9]
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: Set up Python ${{ matrix.python-version }}
60+
uses: actions/setup-python@v2
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
- name: "Setup environment"
64+
uses: "networktocode/gh-action-setup-poetry-environment@v2"
65+
- name: "Linting: Flake8"
66+
run: |
67+
poetry run flake8 netopsio/ --ignore E501

.github/workflows/unit-tests.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Testing
1+
name: "Unit Testing"
22

33
on:
44
push:
@@ -7,23 +7,20 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
build:
11-
10+
unit_tests:
1211
runs-on: ubuntu-latest
1312
strategy:
1413
fail-fast: true
1514
matrix:
16-
python-version: [3.8, 3.9]
17-
15+
python-version: ["3.8", "3.9", "3.10"]
1816
steps:
1917
- uses: actions/checkout@v2
2018
- name: Set up Python ${{ matrix.python-version }}
2119
uses: actions/setup-python@v2
2220
with:
2321
python-version: ${{ matrix.python-version }}
24-
- name: Install Poetry, Install Dependencies, and Execute Unit Tests
22+
- name: "Setup environment"
23+
uses: "networktocode/gh-action-setup-poetry-environment@v2"
24+
- name: Execute Unit Tests
2525
run: |
26-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
27-
source $HOME/.poetry/env
28-
poetry install
29-
cd netopsio; poetry run ./manage.py test; cd -
26+
cd netopsio; poetry run ./manage.py test; cd -

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.10-slim-bullseye
2+
3+
WORKDIR /opt/netopsio
4+
5+
ENV PATH="${PATH}:/root/.local/bin"
6+
7+
EXPOSE 8000
8+
9+
COPY netopsio /opt/netopsio
10+
11+
COPY pyproject.toml .
12+
13+
COPY poetry.lock .
14+
15+
# hadolint ignore=DL3008
16+
RUN apt-get update && \
17+
apt-get install -y --no-install-recommends nmap iputils-ping traceroute curl && \
18+
apt-get autoremove -y && \
19+
apt-get clean all && \
20+
rm -rf /var/lib/apt/lists/*
21+
22+
# hadolint ignore=DL3059
23+
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -o /tmp/install-poetry.py && \
24+
python /tmp/install-poetry.py && \
25+
rm -f /tmp/install-poetry.py
26+
27+
# hadolint ignore=DL3059
28+
RUN poetry config virtualenvs.create false && \
29+
poetry config installer.parallel false && \
30+
poetry install
31+
32+
CMD ["./manage.py", "runserver", "0.0.0.0:8000", "--insecure"]

0 commit comments

Comments
 (0)