Skip to content

Commit

Permalink
Update local and remote build
Browse files Browse the repository at this point in the history
  • Loading branch information
krakerag committed Nov 16, 2023
1 parent af99966 commit b65b892
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Build docker image
run: docker build -t dancer .
- name: Build environment
run: |
apt-get update && \
apt-get upgrade -y && \
apt-get install -y less wget && \
apt-get install -y build-essential && \
apt-get install -y libdancer-perl
- name: Run docker image with entrypoint
run: docker run -d dancer

- name: Validate container
run: docker container ls
run: perl app.pl &

- name: Run curl to ensure endpoint responds
run: curl -i http://127.0.0.1:3000
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM ubuntu:18.04
FROM ubuntu:latest
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y less wget && \
apt-get install -y build-essential && \
apt-get install -y libdancer-perl
COPY . /opt
WORKDIR /opt
EXPOSE 3000
ENTRYPOINT [ "perl", "app.pl" ]
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ You can also run the below commands in a Gitpod instance without needing any con

Build the image in Docker first: `docker build -t dancer .`

Once image is built, you can sync the folder in and run it: `docker run --rm -it -p 3001:3000 -v $(pwd):/opt -w /opt dancer`
Once image is built, you can sync the folder in and run it: `docker run -d -p 3000:3000 -v $(pwd):/opt -w /opt dancer`

This will run the docker image and map the internal port 3000 to the port 3001 of the host system. It will also map the /opt directory of the container to the current directory of the host system.
This will run the docker image and map the internal port 3000 to the port 3000 of the host system. It will also map the /opt directory of the container to the current directory of the host system.

It will show you a prompt like this: `root@6e055fa48a34:/opt#`
This will launch the Dancer application in the container and you can visit it from your desktop by browsing to: http://127.0.0.1:3000/

You're ready to bootstrap the app with: `perl app.pl`
## Continual work

This will launch the Dancer application in the container and you can visit it from your desktop by browsing to: http://127.0.0.1:3001/
Run `docker container ls` and you will see something like this:

## Continual work
```
❯ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c0306495fc74 dancer "perl app.pl" 4 seconds ago Up 4 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp laughing_jemison
```

Use `ctrl-c` to stop serving content and `exit` to stop the container
You can now stop your container by running `docker stop c0306495fc74`

You can re-run the `docker run` command from above to resync the local folder and prepare to relaunch the app
Update your code and rebuild your container with the build command, and re-run the container with your run command above.
2 changes: 1 addition & 1 deletion app.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Dancer;

get '/' => sub {
return "Dancer is responding inside Docker correctly";
return "Dancer is responding inside Docker container";
};

dance;

0 comments on commit b65b892

Please sign in to comment.