-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #599 from fragforce/dev
Update prod - GH actions
- Loading branch information
Showing
33 changed files
with
265 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Builder | ||
|
||
env: | ||
BUILD_ARGS: "" | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
- dev | ||
pull_request: | ||
branches: | ||
- master | ||
- dev | ||
|
||
jobs: | ||
build: | ||
name: Build & push docker image | ||
runs-on: ubuntu-latest | ||
env: | ||
IMG_NAME: ${{ github.repository }} | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
dockerfile: [ "web", "worker", "beat" ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Debug | ||
run: | | ||
echo "github.ref -> {{ github.ref }}" | ||
- name: Docker metadata | ||
id: metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ env.IMG_NAME }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }} | ||
- name: Login to GitHub Container Registry | ||
if: env.BUILD_ARGS != '--test' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: Dockerfile.${{ matrix.dockerfile }} | ||
push: ${{ github.event.base_ref =='refs/heads/main' && github.ref_type == 'tag' && !startsWith(github.ref, 'refs/tags/v0.')}} | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} |
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 @@ | ||
FROM python:3.10-slim as base | ||
|
||
# Setup env | ||
ENV LANG C.UTF-8 | ||
ENV LC_ALL C.UTF-8 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONFAULTHANDLER 1 | ||
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml libpq-dev python3-dev postgresql postgresql-client | ||
|
||
FROM base AS python-deps | ||
|
||
# Install pipenv and compilation dependencies | ||
RUN pip install --upgrade pip | ||
RUN pip install pipenv asdf | ||
RUN apt-get update && apt-get install -y --no-install-recommends gcc git python-dev postgresql postgresql-client | ||
|
||
# Install python dependencies in /.venv | ||
COPY Pipfile . | ||
COPY Pipfile.lock . | ||
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy | ||
|
||
|
||
FROM base AS runtime | ||
|
||
# Copy virtual env from python-deps stage | ||
COPY --from=python-deps /.venv /.venv | ||
ENV PATH="/.venv/bin:$PATH" | ||
|
||
# Create and switch to a new user | ||
RUN useradd --create-home appuser | ||
WORKDIR /home/appuser | ||
USER appuser | ||
|
||
# Install application into container | ||
COPY . . | ||
|
||
CMD [ "celery", "-A", "fforg", "worker", "-l", "${CELERY_LOG_LEVEL:-INFO}", "--autoscale=1,1", "--beat" ] |
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 @@ | ||
FROM python:3.10-slim as base | ||
|
||
# Setup env | ||
ENV LANG C.UTF-8 | ||
ENV LC_ALL C.UTF-8 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONFAULTHANDLER 1 | ||
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml libpq-dev python3-dev postgresql postgresql-client | ||
|
||
FROM base AS python-deps | ||
|
||
# Install pipenv and compilation dependencies | ||
RUN pip install --upgrade pip | ||
RUN pip install pipenv asdf | ||
RUN apt-get update && apt-get install -y --no-install-recommends gcc git python-dev postgresql postgresql-client | ||
|
||
# Install python dependencies in /.venv | ||
COPY Pipfile . | ||
COPY Pipfile.lock . | ||
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy | ||
|
||
|
||
FROM base AS runtime | ||
|
||
# Copy virtual env from python-deps stage | ||
COPY --from=python-deps /.venv /.venv | ||
ENV PATH="/.venv/bin:$PATH" | ||
|
||
# Create and switch to a new user | ||
RUN useradd --create-home appuser | ||
WORKDIR /home/appuser | ||
USER appuser | ||
|
||
# Install application into container | ||
COPY . . | ||
|
||
CMD [ "gunicorn", "fforg.wsgi" ] |
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 @@ | ||
FROM python:3.10-slim as base | ||
|
||
# Setup env | ||
ENV LANG C.UTF-8 | ||
ENV LC_ALL C.UTF-8 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONFAULTHANDLER 1 | ||
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml libpq-dev python3-dev postgresql postgresql-client | ||
|
||
FROM base AS python-deps | ||
|
||
# Install pipenv and compilation dependencies | ||
RUN pip install --upgrade pip | ||
RUN pip install pipenv asdf | ||
RUN apt-get update && apt-get install -y --no-install-recommends gcc git python-dev postgresql postgresql-client | ||
|
||
# Install python dependencies in /.venv | ||
COPY Pipfile . | ||
COPY Pipfile.lock . | ||
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy | ||
|
||
|
||
FROM base AS runtime | ||
|
||
# Copy virtual env from python-deps stage | ||
COPY --from=python-deps /.venv /.venv | ||
ENV PATH="/.venv/bin:$PATH" | ||
|
||
# Create and switch to a new user | ||
RUN useradd --create-home appuser | ||
WORKDIR /home/appuser | ||
USER appuser | ||
|
||
# Install application into container | ||
COPY . . | ||
|
||
CMD [ "celery", "-A", "fforg", "worker", "-l", "${CELERY_LOG_LEVEL:-INFO}", "--autoscale=6,2" ] |
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
Oops, something went wrong.