Skip to content

Conversation

Nevexo
Copy link
Contributor

@Nevexo Nevexo commented Dec 11, 2020

Overview

This PR should resolve #160 - the issue seems to be with the entrypoint being encoded with CRLF line endings, I've also added some extra debugging messages to the entrypoint script, to make diagnosing future Docker-related issues easier.

I'd also like to suggest building the cState Dockerfile into an image and publishing it on Docker Hub or GitHub Packages for ease of deployment. This would also make a docker-compose.yaml file possible (or at least, more user friendly). GitHub Actions are able to build the images, it doesn't take long as we're only compiling the site with Hugo at run-time.

I've also updated the Dockerfile to only clone the master branch of cstate/example, and only get the latest commit - this will hopefully improve the build speed of the image.

Changes to Documentation

I'd also like to suggest the following updates to the deploying with Docker wiki page.

# Installing cState with Docker

cState can run on Docker for both production and development purposes. 

## Building the Image

cState (currently) doesn't have a publicly built image, so it must be built manually. You can do this on any machine that has
Docker and Git installed.

1. Clone the main cState repository: `git clone https://github.com/cstate/cstate`
2. Navigate to the cState directory: `cd cstate`
3. Build the image: `docker build -t cstate .` (note: you can add :[version] after cState if you wish to have multiple versions of cState available).


## Run the Container

Once you've built (or pulled) the container, you can run cState. 

`docker run -p 8080:80 --name=cstate -v /var/cstate:/app cstate`

> You can replace 8080 with any other port, this is where cState will listen on the host computer.

> You can replace /var/cstate with any other path, this is where cState's files will be stored, the user managing cState will need access to this directory. 

## Reloading Modifications

Once files have been modified locally, the site must be rebuilt with Hugo. The easiest way to do this is to simply restart the container.

`docker restart cstate`

If restarting the container isn't a possibility, you can manually run hugo with docker exec

\`\`\`
docker exec -it cstate /bin/ash
cd /app
hugo
cp -r /app/public/* /usr/share/nginx/html
\`\`\`

Footnotes

I have some plans for the dockerfile, such as making reloading the files easier (a script that can be executed via docker exec instead of requiring the user to drop into a shell?) - but I'll bring these up in their own issue in due course.

I've based this PR from the master branch as cState currently doesn't build from the dev branch, but I can rebase it if required.

mistermantas and others added 2 commits November 28, 2020 15:55
These changes replace the CRLF line endings on entrypoint.sh (cstate#160) and adds more debugging messages for diagnosing issues with the docker side of cState in the future.
@mistermantas
Copy link
Member

I've updated the documentation on the wiki for v5 (this is the next release version).

I'd also like to suggest building the cState Dockerfile into an image and publishing it on Docker Hub or GitHub Packages for ease of deployment. This would also make a docker-compose.yaml file possible (or at least, more user friendly). GitHub Actions are able to build the images, it doesn't take long as we're only compiling the site with Hugo at run-time.

Do you mean there's a way for me to automatically set up publishing with Docker using GitHub Actions?

Will merge soon, just need to figure that bit out I suppose.

@Nevexo
Copy link
Contributor Author

Nevexo commented Dec 12, 2020

This action should be able to build and deploy the image to docker hub yes, https://github.com/marketplace/actions/build-and-push-docker-images

You'll need to make an account/org for cState on Docker hub (or work out how GitHub Packages works).

@mistermantas mistermantas changed the base branch from master to dev December 15, 2020 18:36
@mistermantas mistermantas merged commit 9556f03 into cstate:dev Dec 15, 2020
@mistermantas mistermantas mentioned this pull request Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker instance only shows nginx welcome
2 participants