Skip to content

Commit

Permalink
Add docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejMecka committed Oct 12, 2019
1 parent d86d7bb commit f22e146
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
13 changes: 13 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
const fs = require('fs');

// File path on how we know it's a docker instance
const dockerEnvFile = '/.dockerenv';

module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('styles');
eleventyConfig.addPassthroughCopy('assets');
eleventyConfig.addPassthroughCopy({
'node_modules/nes.css/css': 'assets/nes.css'
});

// This is so we can expose the docker port and host to be accesible
if (fs.existsSync(dockerEnvFile)) {
eleventyConfig.setBrowserSyncConfig({
notify: false,
host: '0.0.0.0'
});
}

return {
htmlTemplateEngine: 'njk'
};
Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ npm start

5. Open your browser at http://localhost:8080. You should see the same content as on https://open-pixel-art.com just with a grid on the canvas that helps you better place your pixel.

----

There is also an option for setting up the project via Docker. To get started with the project by using Docker follow the following steps.

1. Build the Docker image

```bash
docker build -t open-pixel-art .`
```

2. Start the Docker image

```bash
docker run -d -p 8080:8080 -it open-pixel-art
```


If the docker image fails to build there's probably an error in your code and the tests fail to pass. If everything is correct you can easily connect by visiting the following url http://localhost:8080. You should see the same content as on https://open-pixel-art.com just with a grid on the canvas that helps you better place your pixel.
You can also verify if it's running by doing `docker ps --all` You will an imamge called `open-pixel-art` and where it's pointing too.
## Contributing a Pixel
If you want to contribute a pixel, you have to open the [`_data/pixels.json`](_data/pixels.json) file. It contains every pixel placed on the canvas.
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Set the base iamge as the latest node alpine veersion
FROM node:lts-alpine

# Copy the work directory so we can use it
COPY . /open-pixel-art
WORKDIR /open-pixel-art

# Install Dependencies
RUN npm install

# Test Code
RUN npm test

# Expose 8080 Port so we can access when we have the Docker instance running
EXPOSE 8080

# Turn on Web Server
CMD ["npm", "start"]

0 comments on commit f22e146

Please sign in to comment.