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

add docker support #298

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

patrickdemers6
Copy link
Collaborator

@patrickdemers6 patrickdemers6 commented Aug 21, 2024

Description

Adding a Dockerfile to make it easier to run the tools provided. This will be most useful for those wishing to run the HTTP proxy in a production environment.

This introduces environment variable support for all flags available on the HTTP proxy. Environment variables are more graceful to use than command line flags when working with Docker.

I've done manual end to end testing, but would appreciate someone else setting this up themselves to help validate.

Fixes #225

Type of change

Please select all options that apply to this change:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Checklist:

Confirm you have completed the following steps:

  • My code follows the style of this project.
  • I have performed a self-review of my code.
  • I have made corresponding updates to the documentation.
  • I have added/updated unit tests to cover my changes.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated
@@ -102,6 +122,13 @@ in lieu of command-line flags when using the above applications:
reduces both latency and the number of Fleet API calls a client makes when
reconnecting to a vehicle after restarting. This is particularly helpful
when using `tesla-control`, which restarts on each invocation.
* `TESLA_TLS_CERT` specifies a TLS certificate file for the HTTP proxy.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the Fleet Telemetry server also allow configuration through environment variables? This could become confusing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generally configured with config.json instead of flags/env vars.

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
)

func init() {
flag.StringVar(&httpConfig.certFilename, "cert", "", "TLS certificate chain `file` with concatenated server, intermediate CA, and root CA certificates")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the root CA certificate required? They usually aren't presented by the server.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be included if the cert is signed by a CA. Running the HTTP proxy without a cert specified fails.

This PR isn't touching the help message but happy to tweak if this is not accurate.

func http.ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error
// ListenAndServeTLS acts identically to ListenAndServe,
// except that it expects HTTPS connections. Additionally, files containing a
// certificate and matching private key for the server must be provided.
// If the certificate is signed by a certificate authority, the certFile should
// be the concatenation of the server's certificate, any intermediates, and the CA's certificate.

README.md Outdated Show resolved Hide resolved
README.md Outdated
Run the image from Docker hub:

```bash
docker run -v ./config:/config teslamotors/vehicle-command:latest -tls-key /config/tls-key.pem -cert /config/tls-cert.pem -key-file /config/fleet-key.pem -host
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you patch up the example OpenSSL command used to generate a self-signed TLS certificate so that the filenames are consistent with this invocation?

It might make more sense to limit to docker build here, and then give the run command after explaining key/certificate requirements in the later section.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping docker run, but switching it to just printing usage. Not diving into all the args since they haven't been explained yet.

with:
bump_version_scheme: ${{ github.event.inputs.version_bump }}
use_github_release_notes: true
tag_prefix: v
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this repo uses this static file for version bump https://github.com/teslamotors/vehicle-command/blob/main/pkg/account/version.txt#L1
not sure if this will work as intended

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I'm open to suggestions on how to manage this better, but the idea is to have client User Agent versions correspond to SDK versions. The Makefile updates it but go build/go get are more common than make.

Copy link
Collaborator Author

@patrickdemers6 patrickdemers6 Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised publish.yml so it automatically creates a GitHub release and pushes to Docker hub when the version.txt file changes.

Open to suggestions on how to test the workflow before merging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested this in a private repository and everything is working well.

GitHub release is auto created and the image is pushed to Docker with latest tag and version tag. When something is merged and version tag doesn't change, nothing is triggered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to make sure the Docker secrets are set and the workflow runner has write access to the repository.

@patrickdemers6 patrickdemers6 force-pushed the add-docker branch 2 times, most recently from 886c0de to 7464d71 Compare August 22, 2024 03:17
README.md Outdated Show resolved Hide resolved
@sethterashima sethterashima linked an issue Aug 23, 2024 that may be closed by this pull request
@patrickdemers6 patrickdemers6 merged commit 96af672 into teslamotors:main Aug 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker image
3 participants