-
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.
* feat: Add Dockerfile with S6-Overlay, Dockerize and nginx #1
- Loading branch information
Showing
12 changed files
with
123 additions
and
1 deletion.
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,44 @@ | ||
name: Build and Push | ||
on: | ||
push: | ||
|
||
env: | ||
NODE_VERSION: "20.10.0" | ||
ALPINE_VERSION: "3.18" | ||
|
||
jobs: | ||
build: | ||
name: Build and Push Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
timeout-minutes: 5 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
timeout-minutes: 5 | ||
|
||
- name: Create Tag | ||
id: tag | ||
run: echo "tag=${{ env.NODE_VERSION }}-$(git rev-parse --short HEAD)-$(date +%s)" >> $GITHUB_OUTPUT | ||
timeout-minutes: 5 | ||
|
||
- name: Login to Docker Hub | ||
if: ${{ github.ref_name == 'main' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ vars.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
timeout-minutes: 5 | ||
|
||
- name: Build and Push Docker Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: | | ||
NODE_VERSION=${{ env.NODE_VERSION }} | ||
ALPINE_VERSION=${{ env.ALPINE_VERSION }} | ||
context: . | ||
push: ${{ github.ref_name == 'main' }} | ||
tags: "improwised/docker-nodejs-base:${{ steps.tag.outputs.tag }}" | ||
timeout-minutes: 10 |
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,62 @@ | ||
# Default version for NodeJS and Alpine Linux | ||
ARG NODE_VERSION | ||
ARG ALPINE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS node | ||
FROM alpine:${ALPINE_VERSION} | ||
|
||
# set version for Dockerrize | ||
ENV DOCKERIZE_VERSION v0.6.1 | ||
|
||
# set version for s6 overlay | ||
ARG S6_OVERLAY_VERSION="3.1.5.0" | ||
ARG S6_OVERLAY_ARCH="x86_64" | ||
|
||
# add Dockerize | ||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
|
||
# Install OS Dependencies | ||
RUN \ | ||
apk add --no-cache --virtual=build-dependencies \ | ||
tar && \ | ||
apk add --no-cache \ | ||
bash \ | ||
curl \ | ||
make \ | ||
gcc \ | ||
g++ \ | ||
nginx \ | ||
&& mkdir -p /etc/nginx \ | ||
&& touch /var/log/nginx/error.log \ | ||
&& rm -Rf /etc/nginx/nginx.conf \ | ||
ca-certificates \ | ||
coreutils \ | ||
tzdata && \ | ||
apk add --no-cache \ | ||
--repository http://nl.alpinelinux.org/alpine/edge/community \ | ||
shadow && \ | ||
# clean up | ||
apk del --purge \ | ||
build-dependencies && \ | ||
rm -rf \ | ||
/tmp/* | ||
COPY --from=node /usr/lib /usr/lib | ||
COPY --from=node /usr/local/lib /usr/local/lib | ||
COPY --from=node /usr/local/include /usr/local/include | ||
COPY --from=node /usr/local/bin /usr/local/bin | ||
|
||
# add 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 | ||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp | ||
RUN tar -C / -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz | ||
|
||
# add s6 optional symlinks | ||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp | ||
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz | ||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp | ||
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz | ||
WORKDIR /app | ||
ADD rootfs / |
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,2 +1,2 @@ | ||
# docker-nodejs-base | ||
Base image for Node.js based applications | ||
Base container image for modern NodeJS applications built on top of Alpine Linux. |
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,5 @@ | ||
#!/usr/bin/with-contenv sh | ||
|
||
set -ex | ||
cat /etc/nginx/nginx.conf | ||
exec nginx; |
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 @@ | ||
longrun |
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,5 @@ | ||
#!/usr/bin/with-contenv bash | ||
|
||
cd /app | ||
# start our node.js application | ||
npm start; |
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 @@ | ||
longrun |
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 @@ | ||
#!/usr/bin/with-contenv bash | ||
|
||
dockerize -stdout /var/log/nginx/error.log -poll |
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 @@ | ||
longrun |
Empty file.
Empty file.
Empty file.