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 Dockerfile and Fly.io deployment instructions #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sawyerknoblich
Copy link

Adds a Dockerfile and instructions for deploying to the free tier of Fly.io for anybody who wants to run the server but isn't familiar with the operations-side of software development.

I saw that #6 also adds a Dockerfile, but that PR seems more focused on 1. pushing an image to an external registry 2. running that pushed image locally. This PR is intended for people who maybe aren't comfortable or knowledgable about provisioning their own server and setting everything up manually, but could follow the doc I've added to run the server for free on a platform that will keep it running automatically and give easy access to server logs. There definitely is some overlap between this PR and #6 though, so feel free to combine this with that one or close this if it's out of scope.

RUN dotnet sln list \
| tail -n +3 \
| xargs -I {} sh -c \
'target="{}"; dir="${target%/*}"; file="${target##*/}"; mkdir -p -- "$dir"; mv -- "$file" "$target"'
Copy link
Author

Choose a reason for hiding this comment

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

Taken from https://stackoverflow.com/a/65390923, this is a hacky thing you need to do to move each of the .csproj files to the proper directory in the docker image. A little annoying but better than hardcoding it because if anything about the project structure is changed (new project added, project renamed, etc) it won't require any changes to the Dockerfile

@Istador
Copy link
Contributor

Istador commented Jul 3, 2022

  1. pushing an image to an external registry

I'd not describe the GitHub Container Registry (GHCR) as an external registry, but rather internal. Because we're on GitHub here and the images will be connected with this repository. (I'd rather say DockerHub is a external registry.)

Though from the perspective of the fly.io runtime, it'd be a external registry.

  1. running that pushed image locally.

The focus is on building and providing docker images automatically on code changes, that are ready to use for all kind of different docker use cases (locally, on a server, on an embedded device, in a cloud, whatever).

The docker-compose.yml and the commands in the readme are just examples on how to use the images.

I'm no expert with fly.io and can't test it without a credit card, but you might be able to instruct flyctl launch with --image to use an already existing image for the application instead of building it from scratch. Untested example:

flyctl launch --image ghcr.io/istador/smo-online-server

@sawyerknoblich
Copy link
Author

sawyerknoblich commented Jul 3, 2022

I'd not describe the GitHub Container Registry (GHCR) as an external registry, but rather internal.

Ah yeah iffy wording on my part, I more just meant "as opposed to building the image locally", but I suppose just calling it "a registry" would have been better.

  1. running that pushed image locally.

My focus on this PR compared to #6 was more about the documentation rather than the possibilities of what you could do with the image. The main goal of this PR was to teach a relatively easy way to deploy the server, and yes it would definitely be even easier if using a pre-built image from GHCR.

use an already existing image for the application instead of building it from scratch

I did just test flyctl deploy --image ghcr.io/istador/smo-online-server:latest and it looks like that deployed successfully, so I'd be more than happy to cut a few steps out of my doc once your PR is merged. This is why I added the disclaimer at the end of my description about there being some overlap between my PR and yours, maybe it's better for this one to wait for yours to be merged and then the only thing mine adds is the new doc.

TheUbMunster referenced this pull request in TheUbMunster/SmoOnlineServer Jul 29, 2022
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.

2 participants