Skip to content

Commit

Permalink
feat: make container work, maybe.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Jun 8, 2024
1 parent a8ba947 commit e66280e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/commune-os/kitsune
ghcr.io/commune-os/docker_redeployer
# generate Docker tags based on the following events/attributes
tags: |
Expand Down
29 changes: 5 additions & 24 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
import { Server } from "https://deno.land/[email protected]/http/server.ts";

const containerName = Deno.env.get("CONTAINER");
const containerImage = Deno.env.get("IMAGE");

async function updateContainer() {
console.log("Updating container");

// Stop the container if it is already running
await Deno.run({ cmd: ["docker", "stop", containerName] }).status();

// Remove the old container if it exists
await Deno.run({ cmd: ["docker", "rm", containerName] }).status();

// Pull the latest version of the container
let status = await Deno.run({
cmd: ["docker", "pull", containerImage],
cmd: ["docker", "compose", "--project-directory", "/compose", "pull"],
}).status();
if (!status.success) {
console.error("Error pulling docker container");
return;
console.error("Error running `docker compose pull`");
}

// Run the new container
// Remove the old container if it exists
status = await Deno.run({
cmd: [
"docker",
"pull",
"-d",
"--name",
containerName,
"-p",
"65534:8943/udp",
containerImage,
],
cmd: ["docker", "compose", "--project-directory", "/compose", "up", "-d"],
}).status();
if (!status.success) {
console.error("Error running docker container");
console.error("Error running `docker compose up -d`");
}
}

Expand Down

0 comments on commit e66280e

Please sign in to comment.