Skip to content

Commit

Permalink
Added experimental docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
katyukha committed Oct 23, 2024
1 parent 7b1d057 commit be05c70
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 16 deletions.
6 changes: 6 additions & 0 deletions build_docker.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash


dub build --d-version OdoodInDocker;
cp ./build/odood ./docker/bin/odood;
(cd ./docker && docker build -t tmp-odood:17 --build-arg ODOO_VERSION=17 --build-arg "ODOOD_DEPENDENCIES=$(cat ../.ci/deps/universal-deb.txt)" .)
1 change: 1 addition & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin
40 changes: 40 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM ubuntu:24.04

ARG ODOO_VERSION
ARG ODOOD_DEPENDENCIES

RUN apt-get update -qq && \
apt-get install -qqq -y --no-install-recommends --auto-remove \
locales \
wget \
ca-certificates \
gnupg \
lsb-release \
tzdata && \
locale-gen en_US.UTF-8 && \
locale-gen en_GB.UTF-8 && \
update-locale LANG="en_US.UTF-8" && update-locale LANGUAGE="en_US:en" \
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
apt-key add - && \
apt-get update -qq && \
apt-get install -qqq -y --no-install-recommends --auto-remove $ODOOD_DEPENDENCIES && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /root/.cache/pip/*

# Set corect locale-related environment variables
ENV LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_ALL="en_US.UTF-8"

COPY ./bin/odood /usr/bin/odood

RUN odood deploy -v "$ODOO_VERSION" --supervisor=odood --log-to-stderr

WORKDIR /opt/odoo

EXPOSE 8069
EXPOSE 8071
EXPOSE 8072

VOLUME ["/opt/odoo/data", "/opt/odoo/backups"]

CMD ["/usr/bin/odood", "server", "run", "--config-from-env"]
2 changes: 1 addition & 1 deletion dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"silly": "1.1.1",
"tabletool": "0.5.0",
"thepath": "2.0.0",
"theprocess": "0.0.6",
"theprocess": "0.0.7",
"tinyendian": "0.2.0",
"unit-threaded": "2.1.9",
"zipper": "0.0.5"
Expand Down
2 changes: 1 addition & 1 deletion subpackages/cli/dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"requests": "2.1.3",
"tabletool": "0.5.0",
"thepath": "2.0.0",
"theprocess": "0.0.6",
"theprocess": "0.0.7",
"tinyendian": "0.2.0",
"unit-threaded": "2.1.9",
"zipper": "0.0.5"
Expand Down
23 changes: 17 additions & 6 deletions subpackages/cli/source/odood/cli/commands/server.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ class CommandServerRun: OdoodCommand {
this() {
super("run", "Run the server.");
this.add(new Flag(
null, "ignore-running", "Ingore running Odoo instance."));
// TODO: Add ability to update odoo config based on environment,
// that is useful when running inside docker containers.
// For example, we can generate new config, and run Odoo
// with newly generated temporary config, instead of rewriting
// existing one.
null, "ignore-running", "Ingore running Odoo instance. (Do not check/create pidfile)."));

version(OdoodInDocker)
this.add(new Flag(
null, "config-from-env", "Apply odoo configuration from envrionment"));
}

public override void execute(ProgramArgs args) {
Expand All @@ -43,6 +42,18 @@ class CommandServerRun: OdoodCommand {
"Odoo server already running!");
}

version(OdoodInDocker) if (args.flag("config-from-env")) {
import std.process: environment;
import std.string: chompPrefix, toLower;
auto config = project.getOdooConfig;
foreach(kv; environment.toAA.byKeyValue) {
string key = kv.key.toLower.chompPrefix("odood_opt_");
config["options"].setKey(key, kv.value);
}
// In case when we running in Docker, we can just rewrite config
config.save(project.odoo.configfile.toString);
}

runner.addArgs(args.argsRest);
debug tracef("Running Odoo: %s", runner);
runner.execv;
Expand Down
2 changes: 1 addition & 1 deletion subpackages/git/dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ copyright "Copyright © 2022-2023, Dmytro Katyukha"
license "MPL-2.0"

dependency "thepath" version=">=1.2.0"
dependency "theprocess" version=">=0.0.5"
dependency "theprocess" version=">=0.0.7"

targetPath "build"
targetType "library"
Expand Down
2 changes: 1 addition & 1 deletion subpackages/git/dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"odood": {"path":"../../"},
"prettyprint": "1.0.9",
"thepath": "2.0.0",
"theprocess": "0.0.6",
"theprocess": "0.0.7",
"unit-threaded": "2.2.0"
}
}
2 changes: 1 addition & 1 deletion subpackages/lib/dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"prettyprint": "1.0.9",
"requests": "2.1.3",
"thepath": "2.0.0",
"theprocess": "0.0.6",
"theprocess": "0.0.7",
"tinyendian": "0.2.0",
"unit-threaded": "2.2.0",
"zipper": "0.0.5"
Expand Down
8 changes: 5 additions & 3 deletions subpackages/lib/source/odood/lib/deploy/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct DeployConfigDatabase {
struct DeployConfigOdoo {
OdooSerie serie;
bool proxy_mode=false;
string http_host="localhost";
string http_host=null;
string http_port="8069";
uint workers=0;

Expand Down Expand Up @@ -129,10 +129,12 @@ struct DeployConfig {
odoo_config["options"].setKey("db_password", database.password);

if (odoo.serie < OdooSerie(11)) {
odoo_config["options"].setKey("xmlrpc_interface", odoo.http_host);
if (odoo.http_host.length > 0)
odoo_config["options"].setKey("xmlrpc_interface", odoo.http_host);
odoo_config["options"].setKey("xmlrpc_port", odoo.http_port);
} else {
odoo_config["options"].setKey("http_interface", odoo.http_host);
if (odoo.http_host.length > 0)
odoo_config["options"].setKey("http_interface", odoo.http_host);
odoo_config["options"].setKey("http_port", odoo.http_port);
}

Expand Down
2 changes: 1 addition & 1 deletion subpackages/utils/dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license "MPL-2.0"

dependency "requests" version=">=2.0.0"
dependency "thepath" version=">=1.2.0"
dependency "theprocess" version=">=0.0.5"
dependency "theprocess" version=">=0.0.7"
dependency "zipper" version="~>0.0.5"

targetPath "build"
Expand Down
2 changes: 1 addition & 1 deletion subpackages/utils/dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"prettyprint": "1.0.9",
"requests": "2.1.3",
"thepath": "2.0.0",
"theprocess": "0.0.6",
"theprocess": "0.0.7",
"unit-threaded": "2.2.0",
"zipper": "0.0.5"
}
Expand Down

0 comments on commit be05c70

Please sign in to comment.