Skip to content

Commit

Permalink
Merge pull request #357 from maykinmedia/upgrade
Browse files Browse the repository at this point in the history
Upgrade to Django 3.2
  • Loading branch information
annashamray authored Jan 30, 2024
2 parents 7c1e2b3 + b1dab37 commit 1e838e2
Show file tree
Hide file tree
Showing 106 changed files with 7,915 additions and 10,070 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
jobs:
tests:
name: Run the Django test suite
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

services:
postgres:
Expand All @@ -28,13 +28,13 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- uses: actions/setup-node@v2-beta
python-version: '3.10'
- uses: actions/setup-node@v4
with:
node-version: '12'
node-version: '18'

- name: Install system packages
run: |
Expand All @@ -61,16 +61,16 @@ jobs:
DB_PASSWORD: ''

- name: Publish coverage report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

docker:
needs: tests

name: Build (and push) Docker image
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set tag
id: vars
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- uses: isort/isort-action@v0.1.0
python-version: '3.10'
- uses: isort/isort-action@v1
with:
requirementsFiles: requirements/dev.txt
sortPaths: "src docs"
Expand All @@ -23,10 +23,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.10'
- name: Install dependencies
run: |
pip install -r requirements/dev.txt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/generate-postman-collection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
matrix:
version: ['v1', 'v2']

name: Run with version v${{ matrix.version }}
name: Run with version ${{ matrix.version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '12'
node-version: '18'
- name: Install dependencies
run: npm install -g openapi-to-postmanv2
- name: Create tests folder
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/generate-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
matrix:
version: [ 'v1', 'v2' ]

name: Run with version v${{ matrix.version }}
name: Run with version ${{ matrix.version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '12'
node-version: '18'
- name: Install dependencies
run: npm install -g @openapitools/openapi-generator-cli
- name: Determing oas path
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lint-oas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
matrix:
version: [ 'v1', 'v2' ]

name: Run with version v${{ matrix.version }}
name: Run with version ${{ matrix.version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '12'
node-version: '18'
- name: Install spectral
run: npm install -g @stoplight/spectral@5
- name: Run OAS linter
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quick-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on: [push]

jobs:
run:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Download docker-compose file
run: wget https://raw.githubusercontent.com/maykinmedia/objects-api/master/docker-compose-quickstart.yml -O docker-compose-qs.yml
- name: Overwrite the docker-compose file to get the "current" one
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
4 changes: 0 additions & 4 deletions .pep8

This file was deleted.

33 changes: 20 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,62 @@
# Stage 1 - Compile needed python dependencies
FROM python:3.7-buster AS build
FROM python:3.10-slim-bullseye AS backend-build

RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
build-essential \
git \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*


WORKDIR /app

COPY ./requirements /app/requirements
RUN pip install pip 'setuptools<59.0' -U
RUN pip install pip --upgrade
RUN pip install -r requirements/production.txt


# Stage 2 - build frontend
FROM mhart/alpine-node:12 AS frontend-build
FROM node:18-alpine AS frontend-build

WORKDIR /app

COPY ./*.json /app/
RUN npm ci

COPY ./gulpfile.js ./webpack.config.js ./.babelrc /app/
COPY ./webpack.config.js ./.babelrc /app/
COPY ./build /app/build/

COPY src/objects/sass/ /app/src/objects/sass/
COPY src/objects/scss/ /app/src/objects/scss/
COPY src/objects/js/ /app/src/objects/js/
RUN npm run build


# Stage 3 - Build docker image suitable for execution and deployment
FROM python:3.7-buster AS production
FROM python:3.10-slim-bullseye AS production

# Stage 3.1 - Set up the needed production dependencies
# install all the dependencies for GeoDjango
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-client \
libgdal20 \
libgeos-c1v5 \
libproj13 \
binutils \
libproj-dev \
gdal-bin \
libgdal-dev \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /usr/local/lib/python3.7 /usr/local/lib/python3.7
COPY --from=build /usr/local/bin/uwsgi /usr/local/bin/uwsgi
COPY --from=backend-build /usr/local/lib/python3.10 /usr/local/lib/python3.10
COPY --from=backend-build /usr/local/bin/uwsgi /usr/local/bin/uwsgi

# Stage 3.2 - Copy source code
WORKDIR /app
COPY ./bin/docker_start.sh /start.sh
RUN mkdir /app/log /app/config

COPY --from=frontend-build /app/src/objects/static/css /app/src/objects/static/css
COPY --from=frontend-build /app/src/objects/static/js /app/src/objects/static/js
# copy frontend build statics
COPY --from=frontend-build /app/src/objects/static /app/src/objects/static

# copy source code
COPY ./src /app/src

RUN useradd -M -u 1000 user
Expand Down
15 changes: 5 additions & 10 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Prerequisites

You need the following libraries and/or programs:

* `Python`_ 3.7 or above
* `Python`_ 3.10 or above
* Python `Virtualenv`_ and `Pip`_
* `PostgreSQL`_ 12 or above with PostGIS extension
* `Node.js`_
Expand Down Expand Up @@ -47,22 +47,20 @@ development machine.
$ git clone [email protected]:maykinmedia/objects-api.git
$ cd objects-api
3. Install all required libraries.
3. Install all required (backend) libraries.

.. code-block:: bash
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements/dev.txt
4. Install the front-end CLI tool `gulp`_ if you've never installed them
before and install the frontend libraries:
4. Install all required (frontend) libraries and build static files.

.. code-block:: bash
$ npm install -g gulp
$ npm install
$ gulp sass
$ npm run build
5. Activate your virtual environment and create the statics and database:

Expand Down Expand Up @@ -94,12 +92,9 @@ development machine.
``src/objects/conf/local.py``. You can base this file on the
example file included in the same directory.

**Note:** You can run watch-tasks to compile `Sass`_ to CSS and `ECMA`_ to JS
using `gulp`_. By default this will compile the files if they change.

.. _ECMA: https://ecma-international.org/
.. _Sass: https://sass-lang.com/
.. _gulp: https://gulpjs.com/


Update installation
Expand All @@ -121,7 +116,7 @@ When updating an existing installation:
$ git pull
$ pip install -r requirements/dev.txt
$ npm install
$ gulp sass
$ npm run build
3. Update the statics and database:

Expand Down
38 changes: 11 additions & 27 deletions build/paths.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
var path = require('path');
var fs = require('fs');
const fs = require('fs');


/** Parses package.json */
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));

/** Name of the sources directory */
var sourcesRoot = 'src/' + pkg.name + '/';
/** Src dir */
const sourcesRoot = 'src/' + pkg.name + '/';

/** Name of the static (source) directory */
var staticRoot = sourcesRoot + 'static/';
/** "Main" static dir */
const staticRoot = sourcesRoot + 'static/';


/**
Expand All @@ -19,32 +18,23 @@ module.exports = {
// Parsed package.json
package: pkg,

// Path to the sass (sources) directory
sassSrcDir: sourcesRoot + 'sass/',
// Path to the scss entry point
scssEntry: sourcesRoot + 'scss/screen.scss',

// Path to the sass (sources) entry point
sassSrc: sourcesRoot + 'sass/**/*.scss',

// Path to the (transpiled) css directory
cssDir: staticRoot + 'css/',

// Path to the fonts directory
fontsDir: staticRoot + 'fonts/',
// Path to the scss (sources) directory
scssSrcDir: sourcesRoot + 'scss/',

// Path to the js entry point (source)
jsEntry: sourcesRoot + 'js/index.js',

// Path to the js (sources) directory
jsSrcDir: sourcesRoot + 'js/',

// Path to js (sources)
jsSrc: sourcesRoot + 'js/**/*.js',

// Path to the js (sources) directory
jsSrcDir: sourcesRoot + 'js/',

// Path to the (transpiled) js directory
jsDir: staticRoot + 'js/',
jsDir: staticRoot + 'bundles/',

// Path to js spec (test) files
jsSpec: sourcesRoot + 'jstests/**/*.spec.js',
Expand All @@ -54,10 +44,4 @@ module.exports = {

// Path to js code coverage directory
coverageDir: 'reports/jstests/',

// Path to HTML templates directory
htmlTemplatesDir: sourcesRoot + 'templates/views',

// Path to HTML includes directory
htmlIncludesDir: sourcesRoot + 'templates/components/'
};
8 changes: 0 additions & 8 deletions build/tasks/build.js

This file was deleted.

Loading

0 comments on commit 1e838e2

Please sign in to comment.