Skip to content

Commit 2b37842

Browse files
authored
Merge pull request #619 from PokeAPI/docker-images
2 parents 868590a + c459e34 commit 2b37842

File tree

6 files changed

+81
-11
lines changed

6 files changed

+81
-11
lines changed

.dockerignore

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
.git
22
.gitignore
3+
.gitmodules
34
CONTRIBUTORS.txt
45
LICENSE.rst
56
README.md
67

7-
*.pyc
8+
**/*.pyc
89
*media/*
910
*static/*
1011
*build/*
11-
*.DS_STORE
12+
**/*.DS_STORE
1213
db.*
1314
venv*
1415
node_modules
16+
Resources
17+
graphql
18+
.vscode
19+
.github
20+
.circleci
21+
docker-compose.yml
22+
.dockerignore
23+
/*.md
24+
/*.js
25+
.env
26+
*pycache*
27+
target

.github/workflows/docker-image.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'staging'
8+
tags:
9+
- '*.*.*'
10+
11+
jobs:
12+
docker:
13+
runs-on: ubuntu-latest
14+
steps:
15+
-
16+
name: Checkout
17+
uses: actions/checkout@v2
18+
with:
19+
submodules: recursive
20+
-
21+
name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v3
24+
with:
25+
# list of Docker images to use as base name for tags
26+
images: |
27+
pokeapi/pokeapi
28+
-
29+
name: Set up QEMU
30+
uses: docker/setup-qemu-action@v1
31+
-
32+
name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v1
34+
-
35+
name: Login to DockerHub
36+
if: github.event_name != 'pull_request'
37+
uses: docker/login-action@v1
38+
with:
39+
username: ${{ secrets.DOCKERHUB_USERNAME_NARAMSIM }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN_NARAMSIM }}
41+
-
42+
name: Build and push
43+
id: docker_build
44+
uses: docker/build-push-action@v2
45+
with:
46+
context: .
47+
file: ./Resources/docker/app/Dockerfile
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
-
52+
name: Image digest
53+
run: echo ${{ steps.docker_build.outputs.digest }}

Resources/compose/docker-compose-prod-graphql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414

1515
graphql-engine:
1616
environment:
17-
HASURA_GRAPHQL_DATABASE_URL: "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/pokeapi"
17+
HASURA_GRAPHQL_DATABASE_URL: "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-pokeapi}"
1818
HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}"
1919

2020
graphiql:

Resources/docker/app/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ENV PYTHONHASHSEED 'random'
66

77
RUN mkdir /code
88
WORKDIR /code
9-
VOLUME /code
109

1110
ADD requirements.txt /code/
1211
RUN \
@@ -16,5 +15,6 @@ RUN \
1615
apk --purge del .build-deps
1716
ADD . /code/
1817

18+
USER nobody
1919
CMD gunicorn config.wsgi:application -c gunicorn.py.ini
20-
EXPOSE 8000
20+
EXPOSE 80

config/docker-compose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
DATABASES = {
66
"default": {
77
"ENGINE": "django.db.backends.postgresql_psycopg2",
8-
"NAME": "pokeapi",
8+
"NAME": os.environ.get("POSTGRES_DB", "pokeapi"),
99
"USER": os.environ.get("POSTGRES_USER", "ash"),
1010
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", "pokemon"),
1111
"HOST": "db",

docker-compose.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ services:
99
db:
1010
image: postgres
1111
environment:
12-
POSTGRES_PASSWORD: 'pokemon'
13-
POSTGRES_USER: 'ash'
14-
POSTGRES_DB: 'pokeapi'
12+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pokemon}
13+
POSTGRES_USER: ${POSTGRES_USER:-ash}
14+
POSTGRES_DB: ${POSTGRES_DB:-pokeapi}
1515
volumes:
1616
- pg_data:/var/lib/postgresql/data
1717
restart: always
@@ -20,6 +20,10 @@ services:
2020
build:
2121
context: .
2222
dockerfile: ./Resources/docker/app/Dockerfile
23+
environment:
24+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pokemon}
25+
POSTGRES_USER: ${POSTGRES_USER:-ash}
26+
POSTGRES_DB: ${POSTGRES_DB:-pokeapi}
2327
volumes:
2428
- .:/code
2529
links:
@@ -53,11 +57,11 @@ services:
5357
- "db"
5458
restart: always
5559
environment:
56-
HASURA_GRAPHQL_DATABASE_URL: postgres://ash:pokemon@db:5432/pokeapi
60+
HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USER:-ash}:${POSTGRES_PASSWORD:-pokemon}@db:5432/${POSTGRES_DB:-pokeapi}
5761
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
5862
HASURA_GRAPHQL_DEV_MODE: "false"
5963
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
60-
HASURA_GRAPHQL_ADMIN_SECRET: pokemon
64+
HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET:-pokemon}
6165
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: anon
6266
HASURA_GRAPHQL_ENABLE_TELEMETRY: "false"
6367
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets

0 commit comments

Comments
 (0)