Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .docker/node/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
yarn install --frozen-lockfile
yarn start
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- uses: actions/checkout@v1
- name: Install dependencies
Expand All @@ -52,10 +51,6 @@ jobs:
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Rename config
env:
PORT: ${{ job.services.mariadb.ports[3306] }}
run: sed "s/3306/$PORT/g" src/config.example.ts > src/config.ts
- name: Build projects, run migrations and seeds
run: |
yarn run build
Expand All @@ -74,8 +69,7 @@ jobs:
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- name: Rename config
run: mv src/config.example.ts src/config.ts

- name: Build
run: docker build -t $ORGANIZATION/$PROJECT_NAME .
- name: Install doctl
Expand Down Expand Up @@ -111,4 +105,4 @@ jobs:
run: |
VERSION=${GITHUB_REF#"refs/tags/"}

kubectl set image deployment/$PROJECT_NAME-deployment $PROJECT_NAME-application=registry.digitalocean.com/$ORGANIZATION/$PROJECT_NAME:$VERSION
kubectl set image deployment/$PROJECT_NAME-deployment $PROJECT_NAME-application=registry.digitalocean.com/$ORGANIZATION/$PROJECT_NAME:$VERSION
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
dist/
src/config.ts
coverage/
.env.local
.idea
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM node:16-alpine AS build

USER node
RUN mkdir /home/node/express-graphql-example/ && chown -R node:node /home/node/express-graphql-example

USER node

WORKDIR /home/node/express-graphql-example

COPY --chown=node:node . .
Expand Down
10 changes: 0 additions & 10 deletions Dockerfile.dev

This file was deleted.

16 changes: 10 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ services:
mysqldb:
image: mysql
restart: unless-stopped
env_file: ./.env
env_file:
- ./.env
- ./.env.local
environment:
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USER=${DATABASE_USER}
Expand All @@ -14,13 +16,15 @@ services:
- 'mysql_data:/mysql/data'

application:
build:
context: .
dockerfile: Dockerfile.dev
image: node:16-alpine
working_dir: /application
command: sh /application/.docker/node/start.sh
depends_on:
- mysqldb
restart: unless-stopped
env_file: ./.env
env_file:
- ./.env
- ./.env.local
ports:
- ${PORT}:${PORT}
environment:
Expand All @@ -32,7 +36,7 @@ services:
links:
- mysqldb
volumes:
- "./src:/application/src"
- ".:/application"


volumes:
Expand Down
3 changes: 3 additions & 0 deletions src/config.example.ts → src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Please set those values via .env file
*/
export default {
port: process.env.PORT || 3010,
database: {
Expand Down