Skip to content

Dockerize #1

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

Open
wants to merge 19 commits into
base: main
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
51 changes: 0 additions & 51 deletions .github/workflows/deploy-now.yaml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/deploy-to-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: deploy-to-server

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
deploy-to-server:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
steps:
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_DATAFRAMETRAINER_KEY }}
known_hosts: 'just-a-placeholder-to-not-get-errors'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.DATAFRAMETRAINER_SERVER_IP }} >> ~/.ssh/known_hosts
working-directory: ./
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Rsync to server
# run: rsync -avz . dataframetrainer@${{ secrets.DATAFRAMETRAINER_SERVER_IP}}:/home/dataframetrainer/test/
run: rsync -avz --exclude='.git' --exclude='node_modules' --exclude='plugins' --exclude='.cache' . dataframetrainer@${{ secrets.DATAFRAMETRAINER_SERVER_IP}}:/home/dataframetrainer/test/
- name: Run docker compose
run: |
ssh dataframetrainer@${{ secrets.DATAFRAMETRAINER_SERVER_IP}} "cd /home/dataframetrainer/test && make down cleanup && make prod_detached"
23 changes: 23 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:18-bullseye

# Set the working directory
WORKDIR /app

# Copy package files to cache dependencies
COPY package.json .
COPY package-lock.json .

# Install system dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
build-essential \
libvips-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js dependencies
RUN npm install
#
# Command to serve the Gatsby site
# CMD ["tail", "-f", "/dev/null"]
CMD ["npm", "run", "dev"]
16 changes: 16 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:18.20.8-alpine3.21

# Set the working directory
WORKDIR /app

# Copy only the public directory into the container
COPY public /app/public

# Install Gatsby CLI globally
RUN npm install -g serve

# Expose the port Gatsby serve uses
EXPOSE 9000

# Command to serve the Gatsby site
CMD ["serve", "-s", "public", "-l", "9000"]
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dev:
docker compose -f docker-compose.yml -f docker-compose.dev.yml up

prod:
docker compose -f docker-compose.yml -f docker-compose.prod.yml up

prod_detached:
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d

down:
docker compose -f docker-compose.yml -f docker-compose.prod.yml down -v --remove-orphans

cleanup:
docker rm -f tobias-pitters-frontend-prod-image
17 changes: 17 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.1"

services:
frontend:
container_name: tobias-pitters-frontend-dev
image: tobias-pitters-frontend-dev-image
restart: on-failure
build:
context: .
dockerfile: Dockerfile.dev
ports:
# The port of the website
- 8000:8000
volumes:
# The local directory to the container
- .:/app
working_dir: /app
13 changes: 13 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.1"

services:
frontend-prod:
container_name: tobias-pitters-frontend-prod
image: tobias-pitters-frontend-prod-image
restart: on-failure
build:
context: .
dockerfile: Dockerfile.prod
ports:
# The port of the website
- 4444:9000
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: "3.1"
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"react-scroll-parallax": "^2.1.2",
"react-slick": "^0.24.0",
"react-spring": "^8.0.27",
"sharp": "^0.25.2",
"sharp": "^0.25.4",
"slick-carousel": "^1.8.1",
"styled-components": "^5.0.0",
"typeface-karla": "0.0.72",
Expand Down Expand Up @@ -78,6 +78,7 @@
"now-build": "npm run build",
"build": "gatsby build",
"develop": "gatsby develop --host=0.0.0.0",
"dev": "gatsby develop --host=0.0.0.0",
"format": "prettier --write src/**/*.{js,jsx}",
"start": "npm run develop",
"serve": "gatsby serve --host=0.0.0.0",
Expand Down
Loading