-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom entrypoint with switch case, updated dockerfiles with ti…
…ny package as entrypoint
- Loading branch information
1 parent
66124bf
commit f108d69
Showing
8 changed files
with
177 additions
and
2 deletions.
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
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
celerybeat-schedule | ||
__pycache__ | ||
.DS_Store | ||
*.pid | ||
|
||
.env | ||
node_modules | ||
|
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 |
---|---|---|
|
@@ -11,4 +11,19 @@ COPY . . | |
EXPOSE 3000 | ||
VOLUME ["/app/build"] | ||
|
||
LABEL name="seoz-admin" \ | ||
version="$VERSION" \ | ||
build="$BUILD" \ | ||
architecture="x86_64" \ | ||
build_date="$NOW" \ | ||
vendor="seoz" \ | ||
maintainer="Luc Michalski <[email protected]>" \ | ||
url="https://github.com/seoz.io/seoz-docker" \ | ||
summary="SeoZ project with Docker" \ | ||
description="SeoZ project with Docker" \ | ||
vcs-type="git" \ | ||
vcs-url="https://github.com/seoz.io/seoz-docker" \ | ||
vcs-ref="$VERSION" \ | ||
distribution-scope="public" | ||
|
||
CMD ["yarn", "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,37 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
set -e | ||
|
||
isArgPassed() { | ||
arg="$1" | ||
argWithEqualSign="$1=" | ||
shift | ||
while [ $# -gt 0 ]; do | ||
passedArg="$1" | ||
shift | ||
case $passedArg in | ||
$arg) | ||
return 0 | ||
;; | ||
$argWithEqualSign*) | ||
return 0 | ||
;; | ||
esac | ||
done | ||
return 1 | ||
} | ||
|
||
case "$1" in | ||
|
||
'bash') | ||
ARGS="" | ||
shift | ||
apk add --update --no-cache nano bash jq | ||
exec /bin/bash $@ | ||
;; | ||
|
||
*) | ||
exec yarn start $@ | ||
;; | ||
esac |
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,74 @@ | ||
FROM python:3-alpine | ||
FROM python:3-alpine AS build | ||
MAINTAINER Luc Michalski <[email protected]> | ||
|
||
WORKDIR /opt/app | ||
|
||
# Install Python and external dependencies, including headers and GCC | ||
RUN apk add --no-cache libffi libffi-dev musl-dev gcc g++ git ca-certificates | ||
|
||
# Update Pip3 | ||
RUN python3 -m pip install -U pi | ||
|
||
# Install Pipenv | ||
RUN pip3 install pipenv | ||
|
||
# Create a virtual environment and activate it | ||
RUN python3 -m venv /opt/venv | ||
|
||
ENV PATH="/opt/venv/bin:$PATH" \ | ||
VIRTUAL_ENV="/opt/venv" | ||
|
||
COPY requirements.txt . | ||
|
||
# Install dependencies into the virtual environment with Pipenv | ||
RUN pip3 install -r requirements.txt | ||
|
||
FROM python:3-alpine AS runtime | ||
MAINTAINER Luc Michalski <[email protected]> | ||
|
||
ARG VERSION | ||
ARG BUILD | ||
ARG NOW | ||
ARG TINI_VERSION=${TINI_VERSION:-"v0.19.0"} | ||
|
||
# Install tini to /usr/local/sbin | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-muslc-amd64 /usr/local/sbin/tini | ||
|
||
# Install runtime dependencies & create runtime user | ||
RUN apk --no-cache --no-progress add ca-certificates openssl libffi openblas libstdc++ \ | ||
&& chmod +x /usr/local/sbin/tini && mkdir -p /opt \ | ||
&& adduser -D seoz -h /opt/seoz -s /bin/sh \ | ||
&& su seoz -c 'cd /opt/seoz; mkdir -p bin config data' | ||
|
||
# Switch to user context | ||
USER seoz | ||
WORKDIR /opt/seoz/data | ||
|
||
# Copy the virtual environment from the previous image | ||
COPY --from=build /opt/venv /opt/venv | ||
|
||
# Activate the virtual environment | ||
ENV PATH="/opt/venv/bin:$PATH" \ | ||
VIRTUAL_ENV="/opt/venv" | ||
|
||
# Set container labels | ||
LABEL name="seoz-server" \ | ||
version="$VERSION" \ | ||
build="$BUILD" \ | ||
architecture="x86_64" \ | ||
build_date="$NOW" \ | ||
vendor="seoz" \ | ||
maintainer="Luc Michalski <[email protected]>" \ | ||
url="https://github.com/seoz.io/seoz-docker" \ | ||
summary="SeoZ project with Docker" \ | ||
description="SeoZ project with Docker" \ | ||
vcs-type="git" \ | ||
vcs-url="https://github.com/seoz.io/seoz-docker" \ | ||
vcs-ref="$VERSION" \ | ||
distribution-scope="public" | ||
|
||
# Container configuration | ||
EXPOSE 5000 | ||
VOLUME ["/opt/seoz/data"] | ||
ENTRYPOINT ["tini", "-g", "--"] | ||
CMD ["./docker-entrypoint.sh"] |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
set -e | ||
|
||
isArgPassed() { | ||
arg="$1" | ||
argWithEqualSign="$1=" | ||
shift | ||
while [ $# -gt 0 ]; do | ||
passedArg="$1" | ||
shift | ||
case $passedArg in | ||
$arg) | ||
return 0 | ||
;; | ||
$argWithEqualSign*) | ||
return 0 | ||
;; | ||
esac | ||
done | ||
return 1 | ||
} | ||
|
||
case "$1" in | ||
|
||
# 'runserver') | ||
# shift | ||
# exec python3 manage.py runserver $@ | ||
# ;; | ||
|
||
'bash') | ||
ARGS="" | ||
shift | ||
apk add --update --no-cache nano bash jq | ||
exec /bin/bash $@ | ||
;; | ||
|
||
*) | ||
exec python3 manage.py runserver $@ | ||
;; | ||
esac |