Skip to content

Commit

Permalink
build: Add an all-in-one container
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Jul 21, 2024
1 parent c5c62de commit 98fc559
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
package: [web, workers, cli]
package: [web, workers, cli, aio]
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down
34 changes: 34 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,37 @@ ARG SERVER_VERSION=nightly
ENV SERVER_VERSION=${SERVER_VERSION}

ENTRYPOINT ["node", "index.mjs"]


################# All-in-one ##############

# Start from the web container as its the one with the most configuration
FROM web AS aio

WORKDIR /app

ARG S6_OVERLAY_VERSION=3.2.0.0
ARG TARGETARCH

# Install s6-overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
RUN case ${TARGETARCH} in \
"amd64") S6_ARCH=x86_64 ;; \
"arm64") S6_ARCH=aarch64 ;; \
esac \
&& echo https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz -O /tmp/s6-overlay-${S6_ARCH}.tar.xz \
&& wget https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz -O /tmp/s6-overlay-${S6_ARCH}.tar.xz \
&& tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz \
&& rm -f /tmp/s6-overlay-${S6_ARCH}.tar.xz

# Install runtime deps
RUN apk add --no-cache monolith

# Copy workers code
COPY --from=workers_builder /prod /app/apps/workers
RUN corepack enable

COPY --chmod=755 ./docker/root/etc/s6-overlay /etc/s6-overlay

ENTRYPOINT ["/init"]
6 changes: 6 additions & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-db-migration/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/command/with-contenv sh
# shellcheck shell=bash

echo "Running db migration script";
cd /db_migrations;
exec node index.js;
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-db-migration/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-db-migration/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-db-migration/run
Empty file.
5 changes: 5 additions & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/svc-web/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/command/with-contenv sh
# shellcheck shell=bash

cd /app/apps/web;
exec node server.js;
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/svc-web/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
5 changes: 5 additions & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/svc-workers/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/command/with-contenv sh
# shellcheck shell=bash

cd /app/apps/workers;
exec pnpm run start:prod;
1 change: 1 addition & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/svc-workers/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.

0 comments on commit 98fc559

Please sign in to comment.