Skip to content

Commit

Permalink
Improve docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
ways committed Sep 11, 2024
1 parent fd3f8f8 commit 872e2e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[bandit]
# B101: assert_used
skips = B101
26 changes: 15 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# syntax=docker/dockerfile:1

# build:
# docker buildx build -t sedr -f Dockerfile .
FROM ubuntu:24.04 AS runtime

# run:
# docker run -it --rm sedr --openapi https://edrisobaric.k8s.met.no/api --url https://edrisobaric.k8s.met.no

FROM ubuntu:24.04
ARG UID=1001
ARG GID=1001

# Create user with home dir
RUN useradd --create-home sedr

# Install python and libeccodes-dev. Create /data.
RUN groupadd --gid $GID sedr && \
useradd \
--create-home \
--shell /bin/false \
--uid $UID \
--gid sedr \
sedr

# Install python
RUN apt-get update && \
apt-get install -y --no-install-recommends python3-dev python3-pip \
apt-get install -y --no-install-recommends python3-dev \
python3-venv && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Set workdir and install app with requirements.
# Set workdir
WORKDIR /app

COPY *.py requirements.txt pytest.ini ./
RUN python3 -m venv ./venv && \
./venv/bin/pip install -r /app/requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Experiment

### Test it out

Run docker image: `docker run -it --rm github.com/metno/sedr --openapi https://edrisobaric.k8s.met.no/api --url https://edrisobaric.k8s.met.no`
Run docker image: `docker run -it --rm docker.io/library/sedr --openapi https://edrisobaric.k8s.met.no/api --url https://edrisobaric.k8s.met.no`

### Results testing existing services

Expand Down
8 changes: 3 additions & 5 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ filterwarnings =
ignore::DeprecationWarning
ignore::pytest.PytestAssertRewriteWarning
addopts = -rP
; log_cli = true
; log_cli_level = WARNING
log_file = ./logs/pytest.log
log_file_level = WARNING
log_cli = true
log_cli_level = WARNING
testpaths =
07-edr-spesifics.py
sedr.py
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist = py310, black, prospector, mypy, bandit
envlist = black, prospector, bandit

[testenv]
[testenv] ; This is a live test against edrisobaric, and should not be run automatically
# See also config file pytest.ini
deps =
-r{toxinidir}/requirements.txt
Expand Down

0 comments on commit 872e2e9

Please sign in to comment.