-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π (v0.9.0): add docker support (#21)
Added docker support ## Commits * β¨ (Dockerfile): add Dockerfile * β¨ (docker-compose.yml): add docker-compose with configs * π§ (run.sh): webserver listen all ips * β¨ (Makefile): add build & push Image name is based on current dir name. * π (src/app.py): fix hardcoded vault's ip No more hardcoded vault's ip. Now Vault's ip is retrieved from VAULT_CONF_URL. *βοΈ (Makefile): change image name Changed image name from '<harborurl>/<dirname>' to '<dirname>' for testings purpose. * π§ (docker-compose): update container's ip Updated container's ip from hardcoded to readable from `.env` file. * π₯ (Makefile): removed build & push targets * β¨ (docker/): add docker folder for images repo * π€ (ci/cd): docker build image workflow
- Loading branch information
Showing
8 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Build Docker Image | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build the Docker image | ||
run: cd docker && make build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.PHONY: lint | ||
|
||
lint: | ||
poetry run pylint $(shell git ls-files '*.py') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM python:3.12 | ||
MAINTAINER NicolΓ² Vescera <[email protected]> | ||
|
||
RUN pip install poetry | ||
|
||
RUN mkdir /project | ||
COPY . /project | ||
|
||
WORKDIR /project | ||
|
||
# set envs to activate poetry env | ||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
RUN poetry install | ||
|
||
ENV VIRTUAL_ENV=/project/.venv \ | ||
PATH="/project/.venv/bin:$PATH" | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["./run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
include buildinfo.mk | ||
|
||
.PHONY: all | ||
all: check build push tag | ||
|
||
.PHONY: check | ||
check: | ||
ifeq ($(IMAGE),) | ||
$(error "Missing IMAGE") | ||
endif | ||
ifeq ($(DEPLOYED),) | ||
$(error "Missing DEPLOYED") | ||
endif | ||
|
||
.PHONY: build | ||
build: check | ||
cd .. && docker build -t $(IMAGE):$(shell date +%Y-%m-%d) -f docker/Dockerfile . | ||
|
||
.PHONY: push | ||
push: check | ||
docker push $(IMAGE):$(shell date +%Y-%m-%d) | ||
docker tag $(IMAGE):$(shell date +%Y-%m-%d) $(IMAGE):latest | ||
docker push $(IMAGE):latest | ||
|
||
.PHONY: tag | ||
tag: check | ||
docker tag $(IMAGE):$(DEPLOYED) $(IMAGE):deployed | ||
docker push $(IMAGE):deployed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
IMAGE=harbor1.fisgeo.unipg.it/uninuvola/web | ||
DEPLOYED=2024-09-20 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
services: | ||
web: | ||
networks: | ||
uninuvola: | ||
ipv4_address: $WEB_IP | ||
container_name: web | ||
image: web | ||
build: ./ | ||
env_file: ../.env | ||
|
||
networks: | ||
uninuvola: | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
flask --app src run --debug | ||
flask --app src run --debug --host 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters