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 support? #837

Open
tfsjohan opened this issue Jan 2, 2022 · 9 comments
Open

Docker support? #837

tfsjohan opened this issue Jan 2, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@tfsjohan
Copy link

tfsjohan commented Jan 2, 2022

Any plans to add a docker-compose file to simplify installation locally, like on a raspberry pi?

@fredli74 fredli74 added the enhancement New feature or request label Jan 12, 2022
@fredli74
Copy link
Owner

It's a good idea.

Unfortunately, I have no experience with either creating my own docker containers or Raspberry pi. I'll keep this issue open for now.

@tfsjohan
Copy link
Author

tfsjohan commented Jan 12, 2022 via email

@fredli74
Copy link
Owner

The public server is hosted on Heroku. I would guess that creating a Docker container for this project should be pretty straightforward. It's basically three parts, that could possibly all be run in the same container for personal usage.

  1. node.js webserver
  2. node.js worker service
  3. PostgreSQL database

It does already create and populate the database automatically if it connects and the scserver schema does not exist.

@galonias
Copy link
Contributor

galonias commented Sep 6, 2022

This was fairly easy to do a quick and dirty docker image out of.

Once I managed to figure out the database creation and the token extraction (might be easier with the .env-file creation and the additional step by step in the installation instruction).

  1. Run the installations-steps
  2. Create Dockerfile in the foot folder of smartcharge-dev source:
FROM node:latest

# Create app directory
WORKDIR /opt/smartcharge-dev

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 3000
ADD start.sh /
RUN chmod +x /start.sh

CMD ["/start.sh"]
  1. Create start.sh in the root folder of smartcharge-dev source (replace internal_token and http://192.168.0.200:3000 with your ip-adress and exposed port):

#!/bin/bash

node /opt/smartcharge-dev/dist/server/server.js & node /opt/smartcharge-dev/dist/server/agency.js -d internal_token http://192.168.0.200:3000
  1. Create docker image
docker build . -t galonias/smartcharge-dev
  1. Create docker container
docker run --name smartcharge-dev --network smartcharge -p 3000:3000 -d galonias/smartcharge-dev:latest

@fredli74
Copy link
Owner

fredli74 commented Sep 6, 2022

Thanks for this @galonias!

What would be the best practice regarding PostgreSQL? How did you set up yours? Typically it's not recommended to use a Dockerized PostgreSQL for production, but I can imagine that it would be very nice and convenient for personal use. Maybe step-by-step instructions on how to set up a PostgreSQL container beside the smartcharge Docker container would be sufficient? What do you think?

@fredli74
Copy link
Owner

fredli74 commented Sep 6, 2022

although maybe a fully ready-made single-user smartcharge setup with server, worker, and PSQL using docker-compose could be nice in the end

@galonias
Copy link
Contributor

galonias commented Sep 6, 2022

I have a PSQL docker container which I’ve reused for this purpose. I didn’t bother setting up a secondary instance.

Having a dedicated single user in one docker container would be optimal for easy setup. You can probably borrow some inspiration from Teslamate and their docker-compose file, https://docs.teslamate.org/docs/installation/docker

@tfsjohan
Copy link
Author

tfsjohan commented Oct 11, 2022 via email

@enoch85
Copy link

enoch85 commented Aug 5, 2023

Very interested in this app. Docker would be a great addition. Is it still maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants