-
Notifications
You must be signed in to change notification settings - Fork 7
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 #88 from maykinmedia/feature/api-checks
Added API checks and updated README.
- Loading branch information
Showing
20 changed files
with
331 additions
and
321 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,26 @@ | ||
name: generate-postman-collection | ||
|
||
on: | ||
push: | ||
paths: | ||
- "src/openapi.yaml" | ||
- ".github/workflows/generate-postman-collection.yml" | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12' | ||
- name: Install dependencies | ||
run: npm install -g openapi-to-postmanv2 | ||
- name: Create tests folder | ||
run: mkdir -p ./tests/postman | ||
- name: Generate Postman collection | ||
run: openapi2postmanv2 -s ./src/openapi.yaml -o ./tests/postman/collection.json --pretty |
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,36 @@ | ||
name: generate-sdks | ||
|
||
on: | ||
push: | ||
paths: | ||
- "src/openapi.yaml" | ||
- ".github/workflows/generate-sdks.yml" | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12' | ||
- name: Install dependencies | ||
run: npm install -g @openapitools/openapi-generator-cli | ||
- name: Validate schema | ||
run: openapi-generator-cli validate -i ./src/openapi.yaml | ||
- name: Generate Java client | ||
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \ | ||
-o ./sdks/java -g java --additional-properties=dateLibrary=java8,java8=true,optionalProjectFile=false,optionalAssemblyInfo=false | ||
- name: Generate .NET Core client | ||
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \ | ||
-o ./sdks/netcore -g csharp-netcore --additional-properties=optionalProjectFile=false,optionalAssemblyInfo=false | ||
- name: Generate .NET Full Framework client | ||
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \ | ||
-o ./sdks/net -g csharp --additional-properties=optionalProjectFile=false,optionalAssemblyInfo=false | ||
- name: Generate Python client | ||
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \ | ||
-o ./sdks/python -g python --additional-properties=optionalProjectFile=false,optionalAssemblyInfo=false+ |
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,24 @@ | ||
name: lint-oas | ||
|
||
on: | ||
push: | ||
paths: | ||
- src/openapi.yaml | ||
- .github/workflows/lint-oas.yml | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12' | ||
- name: Install spectral | ||
run: npm install -g @stoplight/spectral | ||
- name: Run OAS linter | ||
run: spectral lint ./src/openapi.yaml |
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 |
---|---|---|
@@ -1,91 +1,72 @@ | ||
# This is a multi-stage build file, which means a stage is used to build | ||
# the backend (dependencies), the frontend stack and a final production | ||
# stage re-using assets from the build stages. This keeps the final production | ||
# image minimal in size. | ||
|
||
# Stage 1 - Backend build environment | ||
# includes compilers and build tooling to create the environment | ||
FROM python:3.7-buster AS backend-build | ||
# Stage 1 - Compile needed python dependencies | ||
FROM python:3.7-buster AS build | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
RUN mkdir /app/src | ||
|
||
# Ensure we use the latest version of pip | ||
RUN pip install pip setuptools -U | ||
COPY ./requirements /app/requirements | ||
RUN pip install pip setuptools -U | ||
RUN pip install -r requirements/production.txt | ||
|
||
|
||
# Stage 2 - Install frontend deps and build assets | ||
FROM node:13-buster AS frontend-build | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# Stage 2 - build frontend | ||
FROM mhart/alpine-node:10 AS frontend-build | ||
|
||
WORKDIR /app | ||
|
||
# copy configuration/build files | ||
COPY ./build /app/build/ | ||
COPY ./*.json ./*.js ./.babelrc /app/ | ||
|
||
# install WITH dev tooling | ||
COPY ./*.json /app/ | ||
RUN npm ci | ||
|
||
# copy source code | ||
COPY ./src /app/src | ||
COPY ./gulpfile.js ./webpack.config.js ./.babelrc /app/ | ||
COPY ./build /app/build/ | ||
|
||
# build frontend | ||
COPY src/objects/sass/ /app/src/objects/sass/ | ||
COPY src/objects/js/ /app/src/objects/js/ | ||
RUN npm run build | ||
|
||
|
||
# Stage 3 - Build docker image suitable for production | ||
FROM python:3.7-buster | ||
# Stage 3 - Build docker image suitable for execution and deployment | ||
FROM python:3.7-buster 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 \ | ||
procps \ | ||
vim \ | ||
postgresql-client \ | ||
# lxml deps | ||
# libxslt \ | ||
libgdal20 \ | ||
libgeos-c1v5 \ | ||
libproj13 \ | ||
&& 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 | ||
|
||
# Stage 3.2 - Copy source code | ||
WORKDIR /app | ||
COPY ./bin/docker_start.sh /start.sh | ||
RUN mkdir /app/log | ||
RUN mkdir /app/media | ||
|
||
# copy backend build deps | ||
COPY --from=backend-build /usr/local/lib/python3.7 /usr/local/lib/python3.7 | ||
COPY --from=backend-build /usr/local/bin/uwsgi /usr/local/bin/uwsgi | ||
COPY --from=backend-build /app/src/ /app/src/ | ||
RUN mkdir /app/log /app/config | ||
|
||
# copy frontend build statics | ||
COPY --from=frontend-build /app/src/objects/static /app/src/objects/static | ||
|
||
# copy source code | ||
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 ./src /app/src | ||
|
||
RUN useradd -M -u 1000 maykin | ||
RUN chown -R maykin /app | ||
|
||
# drop privileges | ||
USER maykin | ||
|
||
ARG COMMIT_HASH | ||
ARG RELEASE | ||
ENV GIT_SHA=${COMMIT_HASH} | ||
ENV RELEASE=${RELEASE} | ||
|
||
ENV DJANGO_SETTINGS_MODULE=objects.conf.docker | ||
|
||
ARG SECRET_KEY=dummy | ||
|
||
# Run collectstatic, so the result is already included in the image | ||
RUN python src/manage.py collectstatic --noinput | ||
|
||
LABEL org.label-schema.vcs-ref=$COMMIT_HASH \ | ||
org.label-schema.vcs-url="https://github.com/maykinmedia/objects-api" \ | ||
org.label-schema.version=$RELEASE \ | ||
org.label-schema.name="objects API" | ||
|
||
EXPOSE 8000 | ||
CMD ["/start.sh"] | ||
CMD ["/start.sh"] |
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.