A memorandum for me who forgets to work I plan to operate git from pycharm If you do this, you will be able to work without polluting your computer.
So do it Do it anyway
I hope git can be used because it is convenient in many ways.
First, download Git from the following site https://git-for-windows.github.io/
After that, if you follow the road, the installation is completed The detailed route is difficult to explain, so check it out.
At the console
$ git config --global user.name" username "
$ git config --global user.email" email address "`
Type in to complete registration
Create a github account, go to the github homepage and create a repository with new repository from "+" on the upper right Decide the name by Repository name Decide whether it is public or private and click create repository
Then a meaningful url will appear on the screen, so copy it and go to the terminal
You can issue a url even from Code, so let's do it from here when cloning
Go to the directory where you want to put your git project and git clone <url>
By doing this, a directory connected to git will be created, so open pycharm or anything
The directory is completed, but as it is, anything will be shared on github, so create .gitignore
Create a file named .gitignore
directly under the directory
https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore If you are using JetBeain series IDE, copy and paste the above source code I don't know about other IDEs
Add the path of the file you do not want to share here This will prevent git from sharing files that you don't want to share with others, such as notes.
After finishing the work on the github side, the next work is docker
This is packed with everything from installing Docker for desktop to linking with pycharm. https://qiita.com/Denpa_Ghost/items/caeddaa29bd9d7514cce
Create docker-conpose.yml directly under the directory and copy and paste the following
docker-compose.yml
version: '3'
services:
app:
build: docker/python
tty: true
volumes:
- ./app/:/app
working_dir: /app
build:
specifies the storage destination of dockerfile
Whether tty:
will be in a standby state after startup
Required because it will fall immediately if there is nothing moving with false or blank
volumes:
has the role of connecting the folder of the host machine and the folder in the container.
The left is the host machine, the right is inside the container
If there is no folder on the host side, a new folder will be created.
working_dir:
specifies the default working area
After creating docker-compose.yml, create dockerfile in the path specified by build:
If you want to run the slack bot, copy and paste the following
dockerfile
FROM python:latest
RUN mkdir -p /app
RUN pip install slackbot
FROM
sets docker image
RUN
is the command to be entered after the container is created.
Use it when you want to include other packages that are not included in docker image.
In the above case, after creating the container, create the app directory and install the slackbot package. You can do anything you can do mainly with a linux terminal
Once you get here, all you have to do is make a container
In the directory where docker-compose.yml is located
docker-compose up --build -d
You can create a container by doing
First start
docker-compose up --build -d
from next time
docker-compose up -d
Stop all containers
docker-copose stop
Erase all containers
docker-compose down
Erase containers and images together
docker-compose down --rmi
When you want to make a program and execute it
Copy the name of the container you want to run with docker ps
docker exec -it <name> bash
You can access the terminal inside the container with
After that, execute python normally with python main.py
etc.
If you want to run without accessing the terminal
docker exec -it <name> <program name>
Can be executed without entering the terminal with
If you have any questions or complaints, please contact Arakawa It may or may not correspond
Enjoy a comfortable python life with this!
Recommended Posts