@@ -29,7 +29,7 @@ RUN bash -c "sed -i -e 's/daemonize yes/daemonize no/g' /etc/redis/redis.conf" | |||||
# Setup redis service | # Setup redis service | ||||
RUN mkdir /etc/service/redis | RUN mkdir /etc/service/redis | ||||
COPY docker/run_redis.sh /etc/service/redis/run | |||||
COPY bubble-server/src/main/resources/docker/run_redis.sh /etc/service/redis/run | |||||
################# | ################# | ||||
### PostgreSQL | ### PostgreSQL | ||||
@@ -44,7 +44,7 @@ RUN bash -c "service postgresql start && sleep 5s && service postgresql status & | |||||
# Setup PostgreSQL service | # Setup PostgreSQL service | ||||
RUN mkdir /etc/service/postgresql | RUN mkdir /etc/service/postgresql | ||||
COPY docker/run_postgresql.sh /etc/service/postgresql/run | |||||
COPY bubble-server/src/main/resources/docker/run_postgresql.sh /etc/service/postgresql/run | |||||
################# | ################# | ||||
### Bubble | ### Bubble | ||||
@@ -60,7 +60,7 @@ COPY docker/bubble.env /bubble/bubble.env | |||||
# Setup Bubble service | # Setup Bubble service | ||||
RUN mkdir /etc/service/bubble | RUN mkdir /etc/service/bubble | ||||
COPY docker/run_bubble.sh /etc/service/bubble/run | |||||
COPY bubble-server/src/main/resources/docker/run_bubble.sh /etc/service/bubble/run | |||||
################# | ################# | ||||
### Main stuff | ### Main stuff | ||||
@@ -29,7 +29,7 @@ RUN bash -c "sed -i -e 's/daemonize yes/daemonize no/g' /etc/redis/redis.conf" | |||||
# Setup redis service | # Setup redis service | ||||
RUN mkdir /etc/service/redis | RUN mkdir /etc/service/redis | ||||
COPY docker/run_redis.sh /etc/service/redis/run | |||||
COPY bubble-server/src/main/resources/docker/run_redis.sh /etc/service/redis/run | |||||
################# | ################# | ||||
### PostgreSQL | ### PostgreSQL | ||||
@@ -44,7 +44,7 @@ RUN bash -c "service postgresql start && sleep 5s && service postgresql status & | |||||
# Setup PostgreSQL service | # Setup PostgreSQL service | ||||
RUN mkdir /etc/service/postgresql | RUN mkdir /etc/service/postgresql | ||||
COPY docker/run_postgresql.sh /etc/service/postgresql/run | |||||
COPY bubble-server/src/main/resources/docker/run_postgresql.sh /etc/service/postgresql/run | |||||
################# | ################# | ||||
### Bubble | ### Bubble | ||||
@@ -60,7 +60,7 @@ COPY docker/bubble.env /bubble/bubble.env | |||||
# Setup Bubble service | # Setup Bubble service | ||||
RUN mkdir /etc/service/bubble | RUN mkdir /etc/service/bubble | ||||
COPY docker/run_bubble_slim.sh /etc/service/bubble/run | |||||
COPY bubble-server/src/main/resources/docker/run_bubble_slim.sh /etc/service/bubble/run | |||||
################# | ################# | ||||
### Main stuff | ### Main stuff | ||||
@@ -11,12 +11,12 @@ | |||||
<groupId>bubble</groupId> | <groupId>bubble</groupId> | ||||
<artifactId>bubble</artifactId> | <artifactId>bubble</artifactId> | ||||
<!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | <!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | ||||
<version>1.4.51</version> | |||||
<version>1.4.52</version> | |||||
</parent> | </parent> | ||||
<artifactId>bubble-server</artifactId> | <artifactId>bubble-server</artifactId> | ||||
<!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | <!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | ||||
<version>1.4.51</version> | |||||
<version>1.4.52</version> | |||||
<repositories> | <repositories> | ||||
<repository> | <repository> | ||||
@@ -11,6 +11,7 @@ import bubble.model.cloud.AnsibleInstallType; | |||||
import bubble.model.cloud.BubbleNode; | import bubble.model.cloud.BubbleNode; | ||||
import bubble.model.cloud.RegionalServiceDriver; | import bubble.model.cloud.RegionalServiceDriver; | ||||
import bubble.service.packer.PackerBuild; | import bubble.service.packer.PackerBuild; | ||||
import org.cobbzilla.util.io.TempDir; | |||||
import org.cobbzilla.util.system.CommandResult; | import org.cobbzilla.util.system.CommandResult; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -66,4 +67,6 @@ public interface ComputeServiceDriver extends CloudServiceDriver, RegionalServic | |||||
default int getSshPort(BubbleNode node) { return 1202; } | default int getSshPort(BubbleNode node) { return 1202; } | ||||
default void prepPackerDir(TempDir tempDir) {} | |||||
} | } |
@@ -12,10 +12,7 @@ import com.github.dockerjava.api.DockerClient; | |||||
import com.github.dockerjava.api.command.CreateContainerCmd; | import com.github.dockerjava.api.command.CreateContainerCmd; | ||||
import com.github.dockerjava.api.command.CreateContainerResponse; | import com.github.dockerjava.api.command.CreateContainerResponse; | ||||
import com.github.dockerjava.api.command.InspectContainerResponse; | import com.github.dockerjava.api.command.InspectContainerResponse; | ||||
import com.github.dockerjava.api.model.Capability; | |||||
import com.github.dockerjava.api.model.Container; | |||||
import com.github.dockerjava.api.model.HostConfig; | |||||
import com.github.dockerjava.api.model.Image; | |||||
import com.github.dockerjava.api.model.*; | |||||
import com.github.dockerjava.core.DefaultDockerClientConfig; | import com.github.dockerjava.core.DefaultDockerClientConfig; | ||||
import com.github.dockerjava.core.DockerClientConfig; | import com.github.dockerjava.core.DockerClientConfig; | ||||
import com.github.dockerjava.core.DockerClientImpl; | import com.github.dockerjava.core.DockerClientImpl; | ||||
@@ -23,20 +20,30 @@ import com.github.dockerjava.transport.DockerHttpClient; | |||||
import com.github.dockerjava.zerodep.ZerodepDockerHttpClient; | import com.github.dockerjava.zerodep.ZerodepDockerHttpClient; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.cobbzilla.util.collection.ArrayUtil; | |||||
import org.cobbzilla.util.collection.MapBuilder; | import org.cobbzilla.util.collection.MapBuilder; | ||||
import org.cobbzilla.util.io.TempDir; | |||||
import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
import java.util.function.Predicate; | import java.util.function.Predicate; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
import static bubble.service.packer.PackerJob.PACKER_IMAGE_PREFIX; | import static bubble.service.packer.PackerJob.PACKER_IMAGE_PREFIX; | ||||
import static com.github.dockerjava.api.model.InternetProtocol.UDP; | |||||
import static java.lang.Boolean.parseBoolean; | import static java.lang.Boolean.parseBoolean; | ||||
import static java.util.Collections.emptyList; | import static java.util.Collections.emptyList; | ||||
import static java.util.Collections.singletonList; | import static java.util.Collections.singletonList; | ||||
import static java.util.concurrent.TimeUnit.SECONDS; | import static java.util.concurrent.TimeUnit.SECONDS; | ||||
import static org.cobbzilla.util.daemon.ZillaRuntime.*; | import static org.cobbzilla.util.daemon.ZillaRuntime.*; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | |||||
import static org.cobbzilla.util.io.StreamUtil.loadResourceAsStream; | |||||
import static org.cobbzilla.util.io.StreamUtil.stream2file; | |||||
import static org.cobbzilla.util.json.JsonUtil.json; | import static org.cobbzilla.util.json.JsonUtil.json; | ||||
import static org.cobbzilla.util.system.OsType.CURRENT_OS; | import static org.cobbzilla.util.system.OsType.CURRENT_OS; | ||||
import static org.cobbzilla.util.system.OsType.linux; | import static org.cobbzilla.util.system.OsType.linux; | ||||
@@ -56,6 +63,17 @@ public class DockerComputeDriver extends ComputeServiceDriverBase { | |||||
public static final List<ComputeNodeSize> CLOUD_SIZES = singletonList(LOCAL_SIZE); | public static final List<ComputeNodeSize> CLOUD_SIZES = singletonList(LOCAL_SIZE); | ||||
public static final Map<String, ComputeNodeSize> NODE_SIZE_MAP = MapBuilder.build(LOCAL, LOCAL_SIZE); | public static final Map<String, ComputeNodeSize> NODE_SIZE_MAP = MapBuilder.build(LOCAL, LOCAL_SIZE); | ||||
public static final ExposedPort[] SAGE_EXPOSED_PORTS = { | |||||
new ExposedPort(22), new ExposedPort(80), new ExposedPort(443), new ExposedPort(1202) | |||||
}; | |||||
public static final ExposedPort[] NODE_EXPOSED_PORTS = ArrayUtil.append(SAGE_EXPOSED_PORTS, | |||||
new ExposedPort(1080), new ExposedPort(1443), | |||||
new ExposedPort(8888), new ExposedPort(9999), | |||||
new ExposedPort(53, UDP), | |||||
new ExposedPort(500, UDP), new ExposedPort(4500, UDP), | |||||
new ExposedPort(51820, UDP) | |||||
); | |||||
@Override public Map<String, ComputeNodeSize> getSizesMap() { return NODE_SIZE_MAP; } | @Override public Map<String, ComputeNodeSize> getSizesMap() { return NODE_SIZE_MAP; } | ||||
@Override public ComputeNodeSize getSize(ComputeNodeSizeType type) { return LOCAL_SIZE; } | @Override public ComputeNodeSize getSize(ComputeNodeSizeType type) { return LOCAL_SIZE; } | ||||
@@ -119,6 +137,20 @@ public class DockerComputeDriver extends ComputeServiceDriverBase { | |||||
return DockerClientImpl.getInstance(dockerConfig, client); | return DockerClientImpl.getInstance(dockerConfig, client); | ||||
} | } | ||||
private static final String[] PACKER_FILES = {"run_redis.sh", "run_postgresql.sh", "run_supervisor.sh"}; | |||||
@Override public void prepPackerDir(TempDir tempDir) { | |||||
try { | |||||
for (String p : PACKER_FILES) { | |||||
final File destFile = new File(abs(tempDir) + "/roles/common/files/" + p); | |||||
if (!destFile.getParentFile().exists()) die("prepPackerDir: parent dir does not exist: "+abs(destFile.getParentFile())); | |||||
stream2file(loadResourceAsStream("docker/" + p), destFile); | |||||
} | |||||
} catch (Exception e) { | |||||
die("prepPackerDir: "+shortError(e), e); | |||||
} | |||||
} | |||||
@Override public BubbleNode cleanupStart(BubbleNode node) throws Exception { return node; } | @Override public BubbleNode cleanupStart(BubbleNode node) throws Exception { return node; } | ||||
@Override public BubbleNode start(BubbleNode node) throws Exception { | @Override public BubbleNode start(BubbleNode node) throws Exception { | ||||
@@ -133,12 +165,14 @@ public class DockerComputeDriver extends ComputeServiceDriverBase { | |||||
final PackerImage packerImage = getOrCreatePackerImage(node); | final PackerImage packerImage = getOrCreatePackerImage(node); | ||||
final CreateContainerCmd ccr = dc.createContainerCmd(packerImage.getId()) | final CreateContainerCmd ccr = dc.createContainerCmd(packerImage.getId()) | ||||
.withExposedPorts(node.getInstallType() == AnsibleInstallType.sage ? SAGE_EXPOSED_PORTS : NODE_EXPOSED_PORTS) | |||||
.withLabels(MapBuilder.build(new String[][] { | .withLabels(MapBuilder.build(new String[][] { | ||||
{LABEL_CLOUD, cloud.getUuid()}, | {LABEL_CLOUD, cloud.getUuid()}, | ||||
{LABEL_NODE, node.getUuid()} | {LABEL_NODE, node.getUuid()} | ||||
})) | })) | ||||
.withHostConfig(HostConfig.newHostConfig() | .withHostConfig(HostConfig.newHostConfig() | ||||
.withCapAdd(Capability.NET_ADMIN) | .withCapAdd(Capability.NET_ADMIN) | ||||
.withCapAdd(Capability.SYS_MODULE) | |||||
.withCapAdd(Capability.SYS_ADMIN)); | .withCapAdd(Capability.SYS_ADMIN)); | ||||
final CreateContainerResponse response = ccr.exec(); | final CreateContainerResponse response = ccr.exec(); | ||||
final long start = now(); | final long start = now(); | ||||
@@ -202,7 +202,7 @@ public class AccountPlan extends IdentifiableBase implements HasNetwork { | |||||
.setFootprint(getFootprint()) | .setFootprint(getFootprint()) | ||||
.setComputeSizeType(plan.getComputeSizeType()) | .setComputeSizeType(plan.getComputeSizeType()) | ||||
.setStorage(storage.getUuid()) | .setStorage(storage.getUuid()) | ||||
.setLaunchType(hasForkHost() && hasLaunchType() ? getLaunchType() : LaunchType.node) | |||||
.setLaunchType(hasLaunchType() ? getLaunchType() : LaunchType.node) | |||||
.setForkHost(hasForkHost() ? getForkHost() : null) | .setForkHost(hasForkHost() ? getForkHost() : null) | ||||
.setAdminEmail(hasAdminEmail() ? getAdminEmail() : null); | .setAdminEmail(hasAdminEmail() ? getAdminEmail() : null); | ||||
} | } | ||||
@@ -168,7 +168,7 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco | |||||
} else { | } else { | ||||
final String forkHost = request.getForkHost(); | final String forkHost = request.getForkHost(); | ||||
if (empty(forkHost)) { | if (empty(forkHost)) { | ||||
request.setName(newNodeHostname()+"."+newNetworkName()+"."+domain.getName()); | |||||
request.setName(newNetworkName()); | |||||
request.setDomain(domain.getUuid()); | request.setDomain(domain.getUuid()); | ||||
} else { | } else { | ||||
@@ -217,6 +217,9 @@ public class PackerJob implements Callable<List<PackerImage>> { | |||||
copyFile(jar, new File(abs(bubbleFilesDir)+"/bubble.jar")); | copyFile(jar, new File(abs(bubbleFilesDir)+"/bubble.jar")); | ||||
copyScripts(bubbleFilesDir); | copyScripts(bubbleFilesDir); | ||||
// copy assets required by compute driver | |||||
computeDriver.prepPackerDir(tempDir); | |||||
final String imageName = PACKER_IMAGE_NAME_TEMPLATE | final String imageName = PACKER_IMAGE_NAME_TEMPLATE | ||||
.replace(INSTALL_TYPE_VAR, installType.name()) | .replace(INSTALL_TYPE_VAR, installType.name()) | ||||
.replace(SAGE_NET_VAR, truncate(domainname(), 19)) | .replace(SAGE_NET_VAR, truncate(domainname(), 19)) | ||||
@@ -1,3 +1,3 @@ | |||||
# Do not edit this file directly | # Do not edit this file directly | ||||
# Use _set_version to update the Bubble version in all files | # Use _set_version to update the Bubble version in all files | ||||
bubble.version=Adventure 1.4.51 | |||||
bubble.version=Adventure 1.4.52 |
@@ -0,0 +1,3 @@ | |||||
#!/bin/bash | |||||
supervisord --nodaemon | |||||
@@ -158,7 +158,7 @@ | |||||
"driverConfig": { | "driverConfig": { | ||||
"regions": [{"name": "local", "internalName": "local"}], | "regions": [{"name": "local", "internalName": "local"}], | ||||
"sizes": [{"name": "local", "type": "local", "internalName": "local"}], | "sizes": [{"name": "local", "type": "local", "internalName": "local"}], | ||||
"os": "ubuntu:20.04", | |||||
"os": "phusion/baseimage:focal-1.0.0alpha1-amd64", | |||||
"packer": { | "packer": { | ||||
"vars": [], | "vars": [], | ||||
"sudo": false, | "sudo": false, | ||||
@@ -3,3 +3,42 @@ | |||||
name: [ 'curl', 'cron', 'iptables', 'openssh-server' ] | name: [ 'curl', 'cron', 'iptables', 'openssh-server' ] | ||||
state: present | state: present | ||||
update_cache: yes | update_cache: yes | ||||
- name: Ensure /service/ dirs exists | |||||
file: | |||||
path: "/service/{{ item }}" | |||||
owner: root | |||||
group: root | |||||
mode: 0755 | |||||
state: directory | |||||
with_items: [ 'redis', 'postgresql', 'supervisor' ] | |||||
- name: Create /service/redis/run | |||||
copy: | |||||
src: run_redis.sh | |||||
dest: /service/redis/run | |||||
owner: root | |||||
group: root | |||||
mode: 0755 | |||||
- name: Ensure redis runs in foreground | |||||
shell: bash -c "sed -i -e 's/daemonize yes/daemonize no/g' /etc/redis/redis.conf" | |||||
- name: Create /service/postgresql/run | |||||
copy: | |||||
src: run_postgresql.sh | |||||
dest: /service/postgresql/run | |||||
owner: root | |||||
group: root | |||||
mode: 0755 | |||||
- name: trust local postgresql users | |||||
shell: bash -c "sed -i -e 's/ md5/ trust/g' $(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d | sort | tail -1)/main/pg_hba.conf" | |||||
- name: Create /service/supervisor/run | |||||
copy: | |||||
src: run_supervisor.sh | |||||
dest: /service/supervisor/run | |||||
owner: root | |||||
group: root | |||||
mode: 0755 |
@@ -125,7 +125,7 @@ | |||||
"driverConfig": { | "driverConfig": { | ||||
"regions": [{"name": "local", "internalName": "local"}], | "regions": [{"name": "local", "internalName": "local"}], | ||||
"sizes": [{"name": "local", "type": "local", "internalName": "local"}], | "sizes": [{"name": "local", "type": "local", "internalName": "local"}], | ||||
"os": "ubuntu:20.04", | |||||
"os": "phusion/baseimage:focal-1.0.0alpha1-amd64", | |||||
"packer": { | "packer": { | ||||
"vars": [], | "vars": [], | ||||
"sudo": false, | "sudo": false, | ||||
@@ -14,7 +14,7 @@ | |||||
<groupId>bubble</groupId> | <groupId>bubble</groupId> | ||||
<artifactId>bubble</artifactId> | <artifactId>bubble</artifactId> | ||||
<!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | <!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | ||||
<version>1.4.51</version> | |||||
<version>1.4.52</version> | |||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
<licenses> | <licenses> | ||||
@@ -10,7 +10,7 @@ This code is available under the GNU Affero General Public License, version 3: h | |||||
<groupId>bubble</groupId> | <groupId>bubble</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | <!-- @@BUBBLE_VERSION@@ this comment must remain above the version tag so that _set_version can update it --> | ||||
<version>1.4.51</version> | |||||
<version>1.4.52</version> | |||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
<licenses> | <licenses> | ||||